How to set the default .Net framework version for projects in visual studio 2010 - visual-studio

How do you set the default framework version for new projects in Visual Studio 2010?

The easiest way I know of is the following
File -> New Project
Select the Framework you want
Create the project
From then on the new project dialog will default to the framework you selected in step #2.

I know that this is a very old question but I needed the answer to it several times now and I keep searching for it. So, I will share my experience here and hopefully in the future I would not need to search for it too long and those who are looking for the same can find it too. I just tested it with Visual Studio 2015. Open the registry hive HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\NewProjectDialog and look for the value FxVersion (REG_SZ type). For me it used to be 4.6.1 and I changed it to 4.6.2. Now when I create a new projects they target .NET v.4.6.2 by default.

Related

How to create a VSIX template for .NET 6

I create a solution with 4 projects. One of them VSIX project, the other is Project Template and 2 of them are Item template. I want to create VSIX because all team use it. Exporting directly item template from visual studio working fine, but it is not good solution for team-works.
I use C# 10 version at my project. I want to create this template to targeting C# 10 language version. However in list there is only .NET Framework 4.8. So in this case, I cannot use record type or other new things.
How can I create a Visual Studio extension for .NET 6? How I target that or is there another way?
I use Visual Studio 2022.
Visual Studio 2022 targets .NET Framework, so you cannot write a VSIX targeting .NET 6 and have it install into VS2022.
That said, if you want to use newer C# features in .NET Framework projects, you can create an SDK-style project and manually change the .csproj file to have TargetFramework net472 and set LangVersion to 10 or whatever you prefer. While this works, it's not a scenario that Microsoft supports.
Note that for VSIX projects this is currently a bit tricky to get working. An example can be found here, however that's quite a complex build so it will require a good level of familiarity with MSBuild to use it as a reference.
Once you have increase the language version, you will also need something like https://www.nuget.org/packages/IsExternalInit to make record types compile correctly for .NET Framework.

How to get NuGet options in Visual Studio 2017 Community?

I am struggling with creating NuGet packages. I am using Visual Studio 2017 Community edition.
I have seen a couple of videos that show a "Pack" option on the menu when right-clicking the project in Solution Explorer. However, I do not have that option. Is this one of the features in the other (non-Community) versions of Visual Studio? I believe I have also seen a "create NuGet package on build" option mentioned somewhere. I cannot find that either.
I have tried various ways of using nuget, dotnet, and msbuild from the command line(s), but haven't had much success. Very frustrating.
Any help is appreciated.
If you really want to use Visual Studio, I would recommend installing an extension that helps you with that problem. For example, this one. The options people have in videos depend on the extensions they have installed. For you, it is the same.
Alternatively, just use the command-line tooling for this as explained here or for .NET Core here or here.
dotnet/msbuild pack is only available for SDK-style projects, but I believe works for all versions of Visual Studio, as well as on the command line. .NET Core introduced these SDK-style projects, which can be identified by <Project Sdk="Microsoft.NET.Sdk">. If your project (.csproj if it's a C# project) doesn't have the Sdk property or import Microsoft.NET.Sdk in either of the two other ways, then it's not an SDK style project and doesn't support packing in this way. Another obvious difference between the two styles of projects is that SDK projects are only a few lines long from the new project template and don't list files in the project, whereas old style projects are typically a full screen long, even from a new project template with only a single class file, and it does list individual files in the project. If you want to continue with this project type, you'll need to use nuget.exe pack and you'll probably want to create a .nuspec file to define some of the package metadata.
However, using SDK style projects is the future, it just takes time for all of Microsoft's existing project types to migrate. It's much simpler to use, so personally I would avoid old style projects unless you're using a project type (like ASP.NET, not ASP.NET Core) that doesn't support it.
All of this is confusing for anyone new to the .NET ecosystem. My recommendation is 1. when you install Visual Studio, when making your workload selections, make sure in the component list that .NET Core is selected, whatever the newest version of .NET Core that is available at the time of installation. When creating a new project in Visual Studio, always select the .NET Core version, or .NET Standard version of any new project template, even if you want to target the (Windows) .NET Framework, in which case you edit the .csproj and change <TargetFramework>netstandard2.0</TargetFramework> to <TargetFramework>net45</TargetFramework>, although I would recommend multi-targeting possible by adding a s to the element name and using a semi-colon separated list: <TargetFrameworks>net45;netstandard2.0</TargetFrameworks>. So, avoid the "Class Library (.NET Framework)" template, instead use "Class Library (.NET Standard)" and then change the target if you have to.
#zivkan led me down the right path. Changing my project types to .Net Core from .Net Framework made all the options I mentioned in my original post available. No extensions were needed.
My .Net Core class library project now has the Pack and Publish options available on the project's context menu. In addition, there is a another tab (Package) on the project properties page. On that page there is a "Generate NuGet package on build" option along with version, name, tags and other properties.
I have done much .Net framework development, but have been ignoring .Net Core and the newer options. I guess I need to dig in and learn about them.

ClosedXML is not compatible with .NETCoreApp 1.1

I'm trying to add ClosedXML and iText7 to my .NETCore project for school. But every single time I try to install these packages I get the same error:
One or more packages are incompatible with .NETCoreApp,Version=v1.1.
Does anyone know a solution for this problem? I work with Visual Studio 2017 Enterprise Edition. Or does anybody has a suggestion to generate Excels and pdfs with .NET Core?
https://www.nuget.org/packages/ClosedXML
As you can see, ClosedXML depends on .NETFramework 4.0.
http://www.dotnetcurry.com/dotnet/1308/dotnet-core-future-of-dotnet-framework
Right-click on the startup project and click properties. In the application tab, click the Target framework dropdown and .NET Framework >= 4.5. You will lose the cross platform compatibility.
I personally haven't found an ideal export/import solution for excel files but maybe this might work for you: https://www.nuget.org/packages/Shaman.EPPlus/

Entity Framework not appearing in Add New Item list in Visual Studio 2017

I created a new MVC project in Visual Studio 2017. I wanted to add an EDMX file (I will be doing database-first) so right clicked on the project and selected Add|New Item.
However, I cannot find the Entity Framework components that were available in the previous versions of Visual Studio. Does anyone know where they went?
I had a similar issue today after i updated my VS to the latest 2017 version. I tried to open an .edmx file in VS2017 and it didn't show the designer view. So i realised i forgot to select Entity Framework tools during the installation:
Everything is back to normal :)
In .NET Framework-based projects, the Entity Framework 6 templates are still there. However, for .NET Core-based projects, I believe you're expected to use the dotnet ef commands. This includes a means of scaffolding a code-first DbContext from an existing database. See ASP.NET Core - Existing Database.
To verify this, I setup a demo project with the following structure:
The New Item/Data dialog for the .NET Framework project:
Note that there is also an EF POCO Generator template available in the Online templates section that may be of interest to you:
I know this is late, but I ran into the same exact issue. After reading some of the other answers, I realized I had created a .Net project with Standard library instead of the Framework library.
I faced this issue, while creating an MVC application on my latest installation of VS2017.
Failed:
Tried installing Entity Framework using Nuget package manager[Install-Package EntityFramework], but failed to show Ado.NET Entity data model
Success:
1. open programs under control panel and select Visual Studio 2017
2. select Change the installation
3. Select Modify installation
4. Select Individual components
5. If SQL server data tools already installed, deselect/uninstall this component and reinstall the same again.
6. uninstall and reinstall SQL Server Data tools
Note: with one component change, other components may also be deleted. You have to recheck while reinstalling

Creating a custom project type for Visual Studio to build Borland C++ Builder projects into Visual Studio

I want to start the develop of a custom project type for Visual Studio that builds a BPR project with Visual Studio.
I need some hints to beginning with this project. Where can I find a template for this type of projects?
My target is to remove the Borland C++Builder's ugly and unstable interface from the development process and work enterely from Visual Studio.
Edit: Oops, I didn't really see that you're about to create a new project type for C++ Builder files. In that case, you have to build a language package. The Visual Studio Extensibility site should get you started. Also have a look at this more specific link.
I'll leave my old answer here for reference, because it might help people who just want to build C++Builder projects without creating a whole new project type :)
You didn't specify the version of Visual Studio, but I'll assume a recent one. In Visual Studio 8 and 9, most project files (all popular ones except Visual C++) are actually MSBuild files and can therefore be built by MSBuild. You can add a simple command line task (Exec) to build your bpr on the command line, or you can create a custom task for this (if you don't find one already available - the search terms should be MSBuild and custom task). This way, both Visual Studio and MSBuild can build anything you like. If you don't have an MSBuild file to start with or want to dive into developing a task, the MSBuild project template for Visual Studio will help you.
Oh, and other than that, if you don't actually need C++Builder things, you might as well export the BPR as a solution (or create a new solution and add the files).
Integrating C++Builder projects into a build process should be a lot easier with C++Builder 2007 or 2009 as both use MSBuild as build system. But then, I think that upgrading to a recent version of C++Builder solves your problem the other way :)

Resources