How to change a Visual Studio project type?

后端 未结 5 1191
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-10 10:18

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

相关标签:
5条回答
  • 2020-12-10 10:43

    Why do you want to change this?

    I would just add another project to the solution with the one you want, move the files, then remove the original project.

    0 讨论(0)
  • 2020-12-10 10:46

    In visual studio the project type is stored inside the .csproj XML file as GUID. You have to change the GUID to define the new project type you want.

    check http://www.mztools.com/Articles/2008/MZ2008017.aspx for some of the availbale GUIDs

    0 讨论(0)
  • 2020-12-10 10:49

    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.

    0 讨论(0)
  • 2020-12-10 10:52

    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

    0 讨论(0)
  • 2020-12-10 10:59

    Small correction: Visual Studio does not keep track of the project template used to create a project. The project system is largely unaware of the initial template used for a project. There are several items in the project system (Project Type for instance) which have the same name as specific templates but this is a coincidence and the two are not definitively corrected.

    The only thing that can really be changed in terms of the project type is essentially the output type. This can have value Class Library, Console Application and Windows Application. You can change this by going to the project property page (right click Properties) and change the Output Type combo box.

    It is possible to have other project types supported by the project system but they are fairly few and are not definitively associated with a project template.

    0 讨论(0)
提交回复
热议问题