如何删除 VisualStudio2008中的项目配置?

我有一个 VisualStudio2008解决方案,我已经在其中导入了许多预先存在的项目。该项目是混合语言的示例代码(C # ,VB,C + +/CLI)。它们目前有多个配置,但是我希望每个项目只有一个“ Debug”配置。

在配置管理器中,我删除了其他配置(例如“ Release”) ,但是当我这样做时,有一条警告消息告诉我,它们不会从单个项目中删除。

实际上,当我导航到一个单独的项目时,它仍然有“发布”和其他配置,即使在解决方案级别只有“调试”。

如何最好地从每个项目中删除这些额外的配置?我是否忽略了在 GUI 中实现这一点的某种方法,还是应该直接编辑项目文件?

40772 次浏览

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".

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.

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

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.

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>