How to create a VSIX template for .NET 6 - visual-studio

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.

Related

How to associate item templates with Project Type in Visual Studio 2019?

I would like to create a new F# Web ASPNET (not Core) Application using the MSBuild based legacy project format, not the SDK project. In Visual Studio 2019, the only available option for this project type is C#. I've attempted to reverse engineer the project setup by creating a new F# class library and modify the ProjectTypeGuids.
The C# Web Application uses the following project type GUIDs
349c5851-65df-11da-9384-00065b846f21 - ASP.NET MVC 5
fae04ec0-301f-11d3-bf4b-00c04f79efbc - C#
On a basic F# .NET Framework class library, I attempted to add the ASP.NET and F# project type guids to the project.
<ProjectTypeGuids>{349C5851-65DF-11DA-9384-00065B846F21};{F2A71F9B-5D33-465A-A702-920D77279786}</ProjectTypeGuids>
This succeeded in adding the web configuration to the project properties, but now I am unable to add any items to the project at all. It looks like in the past you needed to associate the right language templates with the project guid in the registry editor (see this link)
These entries don't appear to be anywhere that I can see in the registry, for any installed version of VS (which at this point is just 2017 and 2019). How can I enable F# item templates for my F# web application?
While not exactly an answer to the question, I think the pain of trying to do this is likely proof that you SHOULDN'T do this. In the end my approach will be to simply implement the Web Application in C#, while keeping as much code as possible in F# targeting netstandard.

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.

Visual Studio 2010 1 Class Library Project Compile 2 DLLs (.NET 3.5 and .NET 4.0)

I have a Visual Studio 2010 Solution with a class library project. What I want to do is compile 2 DLLs on build. I want to compile against .NET 3.5 and .NET 4.0 respectively. Something like below.
myproject\bin\debug\3.5\assembly.dll
myproject\bin\debug\4.0\assembly.dll
Is this possible?
Maybe you'can write a simple problem to execute on each build, it simply does:
make a copy of your working project file (*.csproj, *.vbproj, etc.)
edit the target info from 4.0 to 3.5 (or from 3.5 to 4.0) and update other related properties, it should be simple enough.
call msbuild.
I've used this approach before for different purpose.
The target framework is part of the application project settings that cannot depend on the configuration (unlike build settings).
I'm afraid you will have to create a separate project for each framework version.

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

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.

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