Filip
Filip

Reputation: 3347

Visual studio - can't remove project configurations


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.

Upvotes: 59

Views: 41342

Answers (10)

kaz
kaz

Reputation: 11

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!

Upvotes: 0

Alireza
Alireza

Reputation: 10486

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.

Upvotes: 29

user14176554
user14176554

Reputation:

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.

Upvotes: 0

Christian Cheney
Christian Cheney

Reputation: 41

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

Upvotes: 4

WickedW
WickedW

Reputation: 2601

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.

Upvotes: 0

Sofia Khwaja
Sofia Khwaja

Reputation: 2079

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.

Upvotes: 0

Mike Grimm
Mike Grimm

Reputation: 1254

  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

Upvotes: 104

jay-danger
jay-danger

Reputation: 663

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?

Upvotes: 27

Martin Clemens Bloch
Martin Clemens Bloch

Reputation: 1097

  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.

Upvotes: 36

Filip
Filip

Reputation: 3347

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.

Upvotes: 3

Related Questions