How to change a Visual Studio project type?

Viewed 66233

I finally figured out that Visual Studio keeps track of how you create a project (in other words which project template you select initially) and filters your options later based on that initial decision. The information is kept in the *.csproj file as a <ProjectTypeGuids> element.

Other than just editing the *.csproj file, is there a "right" way to change a project type for an existing project?

Considering the significance of that setting it seems likely there's a place in the GUI to change it, but I couldn't find one. Thanks!

5 Answers

You can modify it in the .csproj file to change the project type, for instance from .Net Core to .Net Standard. Just by changing the content of blabla you are done with the changes.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AssemblyName>...</AssemblyName>
    <RootNamespace>...</RootNamespace>
  </PropertyGroup>

</Project>

But you should take note if you use some external packages, the packages might not be compatible with the new project type. So, you may need to get the compatible packages.

I needed to add WPF support to a project of type "Class Library (.NET CORE)" in this way:

  • edit YourProject.csproj (double click on it) and modify <Project Sdk="Microsoft.NET.Sdk"> to <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
  • add <UseWPF>true</UseWPF> in the group <PropertyGroup>
  • rebuild YourProject

Now you can add a WPF Window

Related