When adding new C# projects in Visual Studio, additional configurations are not created automatically [duplicate]

假装没事ソ 提交于 2020-01-01 04:31:14

问题


I have a Visual Studio C# solution which I have added a new solution configuration to.

When I create new projects in the solution they have Debug and Release configurations only.

Why do they not have the additional configurations?


回答1:


Understanding Build Configurations says:

By default, projects created with Visual Studio include Debug and Release configurations. Debug configurations are automatically configured for debugging an application, and Release configurations are configured for the final release of an application.

So, basically, every time you add a new project to the solution, you choose the type of your new Visual Studio project from a set of preexisting project templates, which only have the Debug and Release configurations.

Visual Studio allows you to export your own project templates and use them subsequently for creating new projects.

What you can do is:

  1. Create a new empty project of the type that you need to create (Class Library, Console Application etc).
  2. Add the desired project configuration to this project (let's name it Test).
  3. Export the template after naming it MyTemplate. Also make sure that the Automatically import the template into Visual Studio checkbox is checked.
  4. Go back to your original solution and add the project by choosing it from the list of available templates - MyTemplate (which now will be listed).

You will have the Test available as a custom project configuration.

[UPDATE]

Alternatively, you should know that it's also possible to create your own Visual Studio Add-ins which could give you more freedom for creating projects based on templates and for automating builds. Check out the following examples:

How to: Programmatically Create Projects

How to: Create Solution and Project Build Configurations



来源:https://stackoverflow.com/questions/16335008/when-adding-new-c-sharp-projects-in-visual-studio-additional-configurations-are

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!