12

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?

haymansfield
  • 5,419
  • 4
  • 34
  • 51
  • Which should they have else?? – bash.d May 02 '13 at 09:50
  • Would be interesting to know "why". Because this is just standard "feature" to add manually each time I think. – Yahya May 02 '13 at 09:59
  • So I have created a third solution configuration "CustomConfig". I guess intuitively I want all projects I add to this solution to have "CustomConfig" as a configuration (They get Debug and Release). Is there no way to set this up? – haymansfield May 02 '13 at 10:05
  • Also when I add a new solution configuration I am given the option to create the corresponding project configurations. Why then can I not specify this for future projects? – haymansfield May 02 '13 at 10:11
  • It is similar but I think my question is a clearer definition of the root problem. – haymansfield May 02 '13 at 10:19
  • If you open the project files in a text editor you can copy/paste the additional configurations in that way. – ben Dec 20 '15 at 21:45

1 Answers1

9

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

Alex Filipovici
  • 31,789
  • 6
  • 54
  • 78
  • 2
    Thank-you, this explains the situation. There is no practical way of automatically creating custom configurations. – haymansfield May 02 '13 at 10:46
  • 1
    Before wasting time trying to make sense of the configuration model in VS, remember that it is a braindead legacy hack that should have been scrapped several versions ago. It simply makes *no* sense. http://msmvps.com/blogs/carlosq/archive/2008/08/29/the-convoluted-build-configuration-of-the-automation-model-envdte-envdte80.aspx – Anders Forsgren May 02 '13 at 11:17
  • @AndersForsgren, +1, very helpful article. – Alex Filipovici May 02 '13 at 11:23