Visual studio enterprise 2017 targeting - visual-studio

When I am creating a project I am missing the targeting framework selection. This is how my installer looks
But still can't select the target framework. Any pointers?

This is expected, it will sort of default you to latest to help you stay current. After creation, you can go into the properties to switch the target framework type. Depending on the type of framework you'd want to use, it is important to select from the "Windows Classic Desktop" and the "Web Previous Versions" project categories, the different flavors of .NET 3 and 4 are only available through these project categories, when you select one of these project types you should also see the Framework Version selector at the bottom of the Creation window:
For the .NET Standard and .NET Core you switch them after creation.

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.

Cannot Select .Net Core Version for New Projects

Until recently, when creating a .Net Core project, I've been able to select what version of Core to use for it. Since a recent update of Visual Studio 2019, any library project I've created for .Net Core has defaulted to version 3.0. There do not appear to be any options during project creation to select a different version.
For the time being, I need to create projects using .Net Core 2.2, so I'm wondering if anyone knows how to get that option back. For now, I've just been manually changing the target version after creation, but that seems hacky, and I suppose it may be leaving me with bundled references I don't need, or omitting ones that I do.
Update
After installing tons of SDKs, I still do not see the option to choose a framework upon project creation. The documentation for Visual Studio 2019 shows the option as it appears for .NET Framework projects:
... but when creating .NET Core or Standard projects, I am not presented with the option to choose the version:
Is the policy, now, that all projects default to the latest, and if you want something else, you have to change it in the project properties?

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.

Cannot add view to ASP.NET MVC 5 project

I'm trying to add a view to an ASP.NET MVC 5 project in Visual Studio 2013, but the Add button is greyed out.
The default installation of Visual Studio was missing some required elements. When I chose ASP.NET and web development, the following options were not selected on the right side of the page.
.NET Framework project and item templates
NET Framework 4.6.2-4.7.1 development tools
Additional Project templates (previous versions)
.NET WebAssembly build tools
(I found this on the Microsoft web site Microsoft Developer Resources (in spanish!)
I got this for ages, all I did was upgrade the nuget packages for Mvc and it fixed it. I suspect that I had a mismatch of versions in the solution.
Update-Package Microsoft.AspNet.Mvc -Version 5.2.3
The version part is optional, but it should mean that all projects get the same version.
You should create a controller first, then it will create a View folder automatically. Try to right click that file then click create new view. Also Copy might be a specific name, you may need to change that name.
Different from the OP issue (as I'm on VS2017) but in case anyone else comes to this question when they've made the same (basic) error as me...
It took me a few minutes to realise that if you type in a new Model class (as seen below) then this is not what the UI wants; it requires you to select an existing Model from the dropdown. Once I created the model and then selected it 'Add' was enabled.

WIX 3.5 Visual Studio Project create Multiple MSI's For .NET Versions of Installed Files

Right now I have a WIX 3.5 project that lives in my VS 2010 solution. It works great and compiles down to 1 MSI.
What I want is to have the 1 project potentially compile down to 2 MSI's. One of the MSI's references a .NET 3.5 DLL that it is installing into the GAC, and the other MSI references a .NET 4.0 assembly that it is also installing into the GAC.
That way I can give the .NET respective MSI's to those depending on what framework they are on.
Is this possible?
Depending on your preference, you can either:
In this Solution panel/Project tree, have two separate projects; a .Net 3.5 and 4.0 projects, with the projects sharing files but different includes/build options.
or
Under the Build tab, pick "Configuration Manager" and "New", using the option to copy the current build to a new configuration. This is similar to having a Release/Debug version.
Here's an overview of this option:
MSDN overview of VS Configuration Manager
The advantage of the first method is the solution pane shows clearly that there are two builds (but its sort of redundant). The second is a bit cleaner, but a bit more hidden (and I'm pretty sure, you can only set the active project to build one configuration at a time).

Resources