52


I have a major problem with project configurations. Everything started when I wanted to add new solution configuration (named "Dev_WithSource") based on existing "Debug" configuration and checked "Create project configurations". For some reason project configurations were registered inside sln file, properly showing in Configuration manager, but "PropertyGroup Condition" blocks in csproj files weren't created. That resulted in "OutputPath not set ..." error.

So, I tried to repeat whole procedure. After deleting all lines mentioning "Dev_WithSource" from sln file, "Dev_WithSource" project configurations are still showing in configuration manager. I searched all csproj and sln file in my solution. Neither of them contain text "Dev_WithSource".

After all that I event tried developing add-in. I can fetch phantom configurations with project.ConfigurationManager.ConfigurationRowNames but I also can't delete them. Am I missing something? Are those configurations stored in some other files and not csproj/sln?

Thanks.

Filip
  • 3,257
  • 2
  • 22
  • 38
  • did you try deleting/renaming the corresponding .user files? – yms Apr 29 '11 at 13:02
  • Where are those files? I have .suo, .vsscc and 5.1.Resharper.User files with same name as solution file. As for projects, I have only csproj and vspscc files. – Filip Apr 29 '11 at 16:26

9 Answers9

98
  1. Access the configuration manager in one of two ways:

    1. From the menus on top: Build > Configuration Manager...
    2. From the drop down listing your configurations on the main tool bar select Configuration Manager...
  2. In the configuration manager dialog under Active solution configuration: choose <Edit...> from the drop down.

    Configuration Manager

  3. A dialog opens showing all the configurations for your solution. Here you can select and click the Remove button.

    Edit Solution Configurations

KyleMit
  • 30,350
  • 66
  • 462
  • 664
Mike Grimm
  • 1,196
  • 7
  • 10
  • 43
    This removes the configuration from the solution but NOT the projects "in case they are still being used" – stannius Oct 28 '13 at 17:51
  • 9
    @stannius you might want to see http://stackoverflow.com/questions/491957/how-do-i-remove-a-project-configuration-in-visual-studio-2008 – nawfal Feb 06 '14 at 10:23
  • 14
    @stannius To remove _Release_ from all the projects: `Get-Project -All | Foreach { $_.ConfigurationMAnager.DeleteConfigurationRow("Release") }` – Alireza Feb 24 '18 at 23:43
  • 1
    @Alireza Can you explain how you run this command in VS? I assume it's powershell? – Jon Barker Oct 25 '18 at 13:35
  • 5
    @JonBarker Go to Tools -> Nuget Package Manager -> Package Manager Console and execute form the console window – Alireza Nov 03 '18 at 09:36
35
  1. Right-click->Unload your project with the configurations you want to remove.
  2. Right-click->Edit project file xml directly.
  3. Delete the Property groups containing conditions containing the name of the platforms/configurations you wish gone.
  4. Save and load project again. Unwanted configurations should be gone.
  5. If a configuration seems set up right but OutPutPath is still "not set", try moving its propertygroup tag up in the xml.
Martin Clemens Bloch
  • 1,047
  • 1
  • 12
  • 28
  • 3
    I wish there was an easier way (perhaps there is) but this is how I end up doing it, unfortunately. – kd7iwp Aug 15 '13 at 20:46
  • "VS Commands for .Net" turns step 1 and 2 into a single step. It also adds some other UI enhancements to VS. Much recommended. – Martin Clemens Bloch Jan 06 '15 at 10:04
  • this works fine for a small solution, but if you have a bigger solution with multiple projects where also certain sources are excluded from certain builds then this is a really bad choice. – AndersK Mar 20 '19 at 07:22
  • 1
    Please check @Alireza solution using `Get-Project -All | Foreach` – Giulio Caccin Jul 24 '19 at 12:23
28

Let's suppose you want to remove "Release" configuration from the entire solution and the projects. So, first you go to Tools -> Nuget Package Manager -> Package Manager Console.

Copy and past the following command in the console to remove the build from all the projects. You may want to replace "Release" with the configuration name you wish to delete.

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

Finally, remove the configuration solution-wise as explained by Mike Grimm's answer.

Alireza
  • 10,237
  • 6
  • 43
  • 59
  • 7
    In case you're wondering where to execute this command: Go to Tools->Nuget Package Manager->Package Manager Console and execute form the console window. – Oz Solomon Mar 19 '18 at 18:01
  • 6
    Similarly you can remove platforms using the `DeletePlatform` method. e.g. `Get-Project -All | Foreach { $_.ConfigurationMAnager.DeletePlatform("Any CPU") }` – Tone Mar 18 '19 at 19:58
  • 1
    This is the real answer! – Patrick Parker Nov 01 '19 at 16:51
  • 1
    Upvoted this like a year ago, just came back because again I have to remove configurations within a 100+ projects solution. This is the answer that actually gets rid of everything I expect. @Tone remark about DeletePlatform is also incredibly helpful. When I execute this in VS2019 I get a `COMException` displayed for each involved project. The change still happens as expected. – grek40 Jan 12 '21 at 10:46
  • @grek40 The exception wouldn't be an issue - as you correctly mentioned. But if one is fussy about it, restarting Visual Studio could prevent the exception- from memory. – Alireza Jan 18 '21 at 00:58
  • Be CAREFUL when pasting this!!! It will execute if you include the newline symbol at the end. – jeyko Mar 22 '21 at 07:44
25

I know this is an old thread, but this was the answer for me:

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

Copied from How do I remove a project configuration in Visual Studio 2008?

Community
  • 1
  • 1
jay-danger
  • 613
  • 8
  • 14
4

You need to remove the configuration from the solution AND the project. From the Configuration Manager:

  1. Active solution configuration > Edit > Remove
  2. Project contexts > Configuration > Edit > Remove
3

I solved this with utility which parses csproj files and inserts necessary propertygroup blocks into csproj files. Old project configurations still appear in configuration manager but I gave up trying to delete them.

Filip
  • 3,257
  • 2
  • 22
  • 38
0

In my case the issue was that the solution file was not in the same folder as project file so I had to copy the nuget folder into the solution folder to resolve this issue.

Sofia Khwaja
  • 1,909
  • 3
  • 17
  • 20
0

In Visual Studio for MAC -

  1. Double click your Solution > Configurations > General.
  2. Click on your 'ConfigToRemove' in the list then Remove (Ensure you tick delete also Configurations in Solution items), then Yes.
  3. Click OK to save your changes.
  4. Now, right Click on Solution and Tools > Edit File.
  5. Go to "GlobalSection(SolutionConfigurationPlatforms) = preSolution" and remove all the Configurations you no longer need otherwise they will still show up in Configuration Mappings even though there are no mappings in the project!
  6. Save and your done.
WickedW
  • 2,331
  • 4
  • 24
  • 54
0

I know I am bit Late but here is complete solution. To remove configuration completely from solution and project property then open .sln file in any IDE as Plain text and delete all information regarding the configuration. NOTE- don't delete GUID values and debug/release configurations Then open .vcxproj file in XML format and delete all information regarding the configuration. This includes fundamental property for it, Platform Toolset and Assosiated property elements in XML language. NOTE- make sure to delete end tags. when you go back to visual studio, click replace all and you are good to go.