简体   繁体   English

Visual Studio 2017 解决方案中丢失的引用

[英]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.我一直在和同事一起做一个项目,我们使用 Visual Studio 2017 作为 IDE,还使用 ​​Git 将版本推送到 VS 存储库。 We had a few problems and decided to start a new project in Visual Studio with the content we already had.我们遇到了一些问题,并决定在 Visual Studio 中使用我们已有的内容开始一个新项目。

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.此外,在 Source > Repos 中,项目文件夹包含所有文件,包括丢失的文件。 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.我尝试删除项目并再次克隆它,尝试仅下载 .zip 文件并离线启动项目,并以管理员身份运行 VS 2017(看来这解决了其他人的类似问题)但没有任何效果。 My coworker (who pushed the project to the repo in first place) can compile normally and is not facing this reference problem.我的同事(首先将项目推送到 repo)可以正常编译并且没有遇到这个参考问题。

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.我们将 VSTS 与 git 存储库一起使用,这种情况一直发生,尤其是在提取更新的解决方案时。 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:您可以在包管理器控制台中运行以下命令来清理 nugget 包:

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).就我而言,在与 master 分支合并后,我在项目文件 (.csproj) 中有冲突。 When resolving the issue VS2019 automatically had unloaded the project file where those conflicts were and I didn't notice.在解决这个问题时,VS2019 自动卸载了那些冲突所在的项目文件,我没有注意到。 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.我曾经在打开 Visual Studio 2015 项目然后拉取新的 git 提交时体验过它。 The new project I was pulling was was set up for Visual Studio 2017 though.不过,我正在拉动的新项目是为 Visual Studio 2017 设置的。

So my VS 2015 was open and dsiplaying the now VS 2017 project.所以我的 VS 2015 是打开的,并且显示了现在的 VS 2017 项目。 I believe it only contained one nuget package, however this was not downloaded correctly and instead the package was displayed as a missing file.我相信它只包含一个 nuget 包,但是没有正确下载,而是将该包显示为丢失的文件。

Maybe this is happening for you too?也许这也发生在你身上?

Same problem in VSC 2021 version 1.63. VSC 2021 版本 1.63 中存在同样的问题。 Solution - Removed project folder from workspace: CTRL+Shift+P, search for and execute the "Workspace: Remove Folder from Workspace" command.解决方案 - 从工作区删除项目文件夹:CTRL+Shift+P,搜索并执行“工作区:从工作区删除文件夹”命令。 Then reopened the project folder and was OK然后重新打开项目文件夹就OK了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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