I have a large solution with number of projects. Some the projects depend on others (never a circular dependency though).
When I tried to remove a dependency of a project, I am getting an error message like "The dependency was added by the project system and cannot be removed". What is the cause for this error? How I can solve this?
I sometimes get this problem when I try to manually edit projects/solutions generated by our CMake system. I solve it manually:
- Open the dependent .vcproj file in your favorite text editor.
- Find <ProjectReference> tag corresponding to the dependency you want to remove (the include attribute of the tag will contain the name of the dependency project).
- Remove the whole <ProjectReference> element (i.e. starting with <ProjectReference> and ending with </ProjectReference> inclusive). Save the file.
- Reload the solution.
I faced the same issue. But i could solve it by following
- Right click project, select Properties.
- Select Framework and References under Common Properties
- Select the references thats not needed.
- Click on Remove Reference.
Or =>
To remove a reference in Visual C#:
- In Solution Explorer, open the References node under the project node.
- Right-click a reference and click Remove
To remove a reference in Visual Basic:
- In Solution Explorer, right-click the My Project node for the project and select Properties.
- Click the References tab.
- In the References list, select the reference you want to remove.
- Click the Remove button
For Visual Studio 2013: On C++ projects (hope the same for others too)
- From the Solution Explorer, select the project and right click to select the properties
- In the properties window, on left pane, select Common properties => References
- Right side of the window, you have the option to Add or Remove the other dependency items.
- Then select OK, to save
If your project only has the .sln file but not any .csproj, you may want to
- check the ProjectReferences property and remove the reference project there
- remove the section from Project to EndProject
- also remove the related rows under GlobalSection(ProjectConfigurationPlatforms)
As an additional point to @malenkiy_scot's above, for ProjectReference items you want to keep, double check the project guid is the correct one for that project. In the dependent .vcproj file, find the ProjectReference tags as above, and for each you want to keep:
- open the referenced project's .vcproj file in a text editor
- find its guid in the ProjectGuid tag
- compare this with Project tag for that reference in the dependent .vcproj file (not case sensitive)
- if it's not the same, replace the guid in the Project tag with the one from the referenced project's ProjectGuid tag
- save the project file and reload the solution
Visual Studio uses the project guid rather than name to determine dependencies. So if you've hand edited the name of the dependency but not the guid (as I did) you get the error.
In VS17 Right-clicking on the References node then selecting OptimiseReferences... is good for helping work out your dependencies. Also Right-click on the project and clicking BuildDependancies... ProjectDependencies that might be where your dependency is being set.
1- RIght click References of the project and click Add Reference...
2- Uncheck dependent projects from the solution tab
来源:https://stackoverflow.com/questions/12818315/error-while-removing-project-dependency-in-vs2010