107

I have a Visual Studio 2008 solution into which I have imported a number of pre-existing projects. The projects are mixed-language sample code (C#, VB, C++/CLI). They currently have multiple configurations, but I want each project only to have only a single "Debug" configuration.

In the configuration manager, I deleted the other configurations (e.g. "Release"), but as I did so there was a warning message to tell me that they would not be deleted from the individual projects.

And indeed when I navigate to an individual project, it still has "Release" and other configurations, even though at the solution level there is only "Debug".

How can I best remove these extra configurations from each project? Am I overlooking some way to do this in the GUI, or should I just edit the project files directly?

6 Answers 6

213

In the Configuration Manager, select "Edit..." in the "Configuration" column for each project (not via the dropdown named Active solution configuration) that has configurations you want to remove.

In the dialog that pops up, mark each unwanted configuration and select "Remove".

9
  • 25
    Thank you! I wish Visual Studio offered a quicker way to remove a configuration across all projects. If you have a dozen projects or so in a solution it's a pain to go through each of them and manually delete the configuration. Aug 23, 2011 at 9:43
  • 1
    @Matthias I beg to differ. And no, it has not been changed (from when I answered this in 2009 up to version 2013).
    – Timbo
    Oct 11, 2014 at 17:42
  • 2
    If I go to the Configuration Manager, delete an active solution configuration via edit, then the configuration is indeed removed from the Configuration Manager. But If you now go to the properties of your project, then the configuration is still there. If you look inside the .vcxproj files, then the configuration is still there. I use Visual Studio 2013 (Professional and Ultimate)
    – Matthias
    Oct 11, 2014 at 18:00
  • 1
    @Matthias Read carefully (especially the part for each project). Maybe the word choice/order in my answer is not properly optimized for best comprehensibility, but that does not change whether this works or not.
    – Timbo
    Oct 11, 2014 at 18:07
  • 1
    @Stefano Ricciardi 5 years later, did you find a solution for such pain? Feb 17, 2018 at 9:31
17

The best way to automate the removal a configuration from all the projects of a solution is done by using Nuget console command to access visual studio apis.

Go to Tools, Nuget Package Manager, Package Manager Console.

From there use:

Get-Project -All | Foreach { $_.ConfigurationManager.DeleteConfigurationRow("Release") }

In this way you have removed all the configurations from all the projects called "Release". I strongly suggest you to always check the differences on your source code versioning sistem, you will see only csproj and in some cases sln files affected, if you are using configuration transformations (like Web.Release.config) they will still be there.

Further information are available on the visual studio version-specific api documentation here, this works from at least VS 2015 for C++, C#, F#, VB languages.

8
  • Can you provide some reference e.g. how you come up with this code? Are there any tutorial? I want to make sure it will not break my project, be able to maintain it myself, and probably use it for other things.
    – javaLover
    Jul 31, 2019 at 10:41
  • Thank! I noticed the topic's tree (top of page) in your link is Docs > .NET > ... > DeleteConfigurationRow. Does it work only for .net solution? Did you also test it for C++ solution?
    – javaLover
    Jul 31, 2019 at 11:20
  • 2
    Worked fine for me, solution of C++ projects. Thanks for the tip! Jul 9, 2020 at 7:35
  • 1
    Just looked through the API again, and it looks like it isn't possible as the access method for the name of a collection is restricted to get learn.microsoft.com/en-us/dotnet/api/….
    – Andy
    Apr 22, 2021 at 16:24
  • 1
    @Terry - I managed to get this error but it occured on a project that was created in an older version of Visual Studio and hadn't been updated. This might also be the issue that was affecting you.
    – Andy
    Apr 22, 2021 at 16:51
15

To help illustrate timbo's answer, here is what he's talking about. Like some of the commenters it took me a while to find this.

enter image description here

3

Doesn't answer this particular question I know but with VS2013 you can open the Property Manager tab, expand all project configurations, do multiple selection using the CTRL or SHIFT keys and delete configurations from multiple projects at once.

2
  • Is this for C++ projects only? I guess the tab you are referring to is the 'View>Other Windows>Property Manager'? Oct 29, 2015 at 2:10
  • This worked perfectly in VS2017. I only wanted to keep two C++configurations (Debug|Release+Win32|x64) across multiple projects so I expanded all of the projects in the Property Manager, clicked the top configuration, scrolled to the bottom and shift-clicked the bottom configuration and then used control-click to de-select the configurations to keep. You must also de-select the names of the projects or delete will not appear in the menu. Then right-click on a selected (not de-selected) configuration and select Remove. Finally, go to Project->Configuration manager and remove the configurations.
    – UweBaemayr
    Oct 7, 2021 at 18:34
1

In VS2017/VS2019, if you drop down the "Active solution configuration", there is an <edit> there that lets you remove a configuration from all projects.

Screenshot showing <edit>

1
  • This removes the configuration from the solution, but not from each project.
    – Alex Angas
    Dec 6, 2022 at 12:41
0

VS2022 now provides the check box to "Remove deleted configurations from all projects where it is unused." on the "Edit Solution Configurations" screen.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.