xarzu
xarzu

Reputation: 9479

Cannot Edit or Add Path to Reference File in Visual Studio 2010

Cannot Edit or Add Path to Reference File , I cannot edit or add a path to a referece file. I have inherited a project at work. When I open the project and go to the references scetion in the Visual Studio 2010 IDE there are some little yellow warning signs showing that there is something amiss with the reference listed there. But when I click on the item and look at the missing path, I find that the name "Path" is in grey suggesting that I cannot edit it and, sure enough, I cannot add the path name to the adjoining field. What causes this? I have the solution file and the project file checked out in edit mode.

When I open the project file, the error list also gives the warnings for each missing reference: "The reference component '(the file name)' cound not be found"

Well, I know where they are but editing the path to point there is the problem.

Upvotes: 12

Views: 22175

Answers (4)

Gil
Gil

Reputation: 11

I also had a problem with adding references i would add a reference and the path is always empty what eventually helped was Right click project > unload project Right click again > Edit project file in project file scroll to bottom and remove group named:

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
....
</Target>

reload project again and build

Upvotes: 0

Meg-90
Meg-90

Reputation: 259

I had the same issue, none of the above solution worked. Only thing I was supposed to do was right click on my sln file, click on "Enable nuget package restore option", save it, close the visual studio. Open it again, clean and rebuild the solution. Visual studio rebuilt the solution successfully.

]Make sure you have clicked on Enable Nuget package restore

Upvotes: 0

KazR
KazR

Reputation: 961

I think in this situation you've got 2 choices:

  1. Remove the broken references and re-add them to the project - this is easy to do if you don't have too many broken references.

  2. Right click on the project file in Solution Explorer and select 'Edit Project File' and manually fix the reference hint paths (the project file is XML). Save, and right-click the project file in Solution Explorer again and select 'Reload Project'.

Upvotes: 11

xarzu
xarzu

Reputation: 9479

Editing the project file by hand found the problem. THe project file is an xml file. It did not take long to find a reference in the path that was wrong.

Upvotes: 2

Related Questions