简体   繁体   中英

Lost references in Visual Studio 2017 solution

I've been working on a project with a coworker and we're using Visual Studio 2017 as IDE and also Git to push the versions to VS repository. We had a few problems and decided to start a new project in Visual Studio with the content we already had.

The weird thing is: when cloned the repository to my computer and synched, some of the references were lost. A yellow triangle appears next to the lost references icons in Solution Explorer, and it doesn't have a path set like the ones that work. Also, inside Source > Repos, the project folder has all files, including the ones that are missing. I tried deleting the project and cloning it again, tried to download only the .zip file and starting the project offline, and also running VS 2017 as administrator (it appears this solved similar problems for others before) and nothing worked. My coworker (who pushed the project to the repo in first place) can compile normally and is not facing this reference problem.

Has anyone ever experienced this issue?

We're using VSTS with a git repository, and this happens all the time, especially when pulling updated solutions. I find a clean and rebuild fixes the problem.

You can run in the Package Manager Console the following command to clean up the nugget packages:

Update-Package -reinstall -ProjectName XYZProjectName

or run it for the whole solution:

Update-Package -reinstall

In my case after a merge with the master branch, I had conflicts in the project file (.csproj). When resolving the issue VS2019 automatically had unloaded the project file where those conflicts were and I didn't notice. A check for that might save time for someone.

I once experienced it when I was having a Visual Studio 2015 project open and then pulling new git commits. The new project I was pulling was was set up for Visual Studio 2017 though.

So my VS 2015 was open and dsiplaying the now VS 2017 project. I believe it only contained one nuget package, however this was not downloaded correctly and instead the package was displayed as a missing file.

Maybe this is happening for you too?

Same problem in VSC 2021 version 1.63. Solution - Removed project folder from workspace: CTRL+Shift+P, search for and execute the "Workspace: Remove Folder from Workspace" command. Then reopened the project folder and was OK

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM