Visual studio - can't remove project configurations
Asked Answered
E

10

57


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.

Eldridgeeldritch answered 29/4, 2011 at 12:48 Comment(2)
did you try deleting/renaming the corresponding .user files?Pimiento
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.Eldridgeeldritch
E
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.

Eldridgeeldritch answered 15/9, 2011 at 15:12 Comment(0)
H
102
  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

Hamel answered 31/7, 2013 at 15:42 Comment(5)
This removes the configuration from the solution but NOT the projects "in case they are still being used"Ake
@Ake you might want to see #492457Midshipmite
@Ake To remove Release from all the projects: Get-Project -All | Foreach { $_.ConfigurationMAnager.DeleteConfigurationRow("Release") }Bighorn
@Bighorn Can you explain how you run this command in VS? I assume it's powershell?Towney
@JonBarker Go to Tools -> Nuget Package Manager -> Package Manager Console and execute form the console windowBighorn
M
36
  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.
Mend answered 23/5, 2013 at 9:13 Comment(4)
I wish there was an easier way (perhaps there is) but this is how I end up doing it, unfortunately.Lander
"VS Commands for .Net" turns step 1 and 2 into a single step. It also adds some other UI enhancements to VS. Much recommended.Mend
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.Copro
Please check @Bighorn solution using Get-Project -All | ForeachWindsor
B
29

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.

Bighorn answered 24/2, 2018 at 23:43 Comment(6)
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.Berndt
Similarly you can remove platforms using the DeletePlatform method. e.g. Get-Project -All | Foreach { $_.ConfigurationMAnager.DeletePlatform("Any CPU") }Mirisola
This is the real answer!Famed
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. @Mirisola 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.Thymic
@Thymic 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.Bighorn
Be CAREFUL when pasting this!!! It will execute if you include the newline symbol at the end.Communicate
K
26

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?

Katharyn answered 8/1, 2017 at 4:31 Comment(2)
Worked for me in VS 2019Sandpit
This is the way. Still tedious to go through multiple projects but at least I am not modifying projects via text file.Ruck
D
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
Dollarfish answered 18/12, 2019 at 16:4 Comment(0)
E
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.

Eldridgeeldritch answered 15/9, 2011 at 15:12 Comment(0)
A
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.

Ankylosis answered 11/10, 2018 at 18:44 Comment(0)
H
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.
Hellfire answered 2/7, 2019 at 12:16 Comment(0)
B
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.

Bowknot answered 7/1, 2021 at 18:23 Comment(0)
G
0

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

Copied from how-do-i-remove-a-project-configuration-in-visual-studio-2008


Edited

You can see the dialog below at the 3rd step given by Mike's answer.

"Edit Solution Configurations" having a checkbox!

Garboil answered 17/9, 2023 at 6:5 Comment(1)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewGarfish

© 2022 - 2024 — McMap. All rights reserved.