Visual Studio Intellisense可以找到参考,但由于缺少参考而构建失败

发布于 2025-02-12 07:51:50 字数 748 浏览 2 评论 0原文

我目前遇到了一个问题(在Visual Studio 2022上),我的解决方案中的测试项目是在我的解决方案中引用其他一些项目。但是,试图构建测试项目会导致这些项目参考的错误。更有趣的是,这个测试项目曾经工作正常。

到目前为止,我已经:

  • Double检查了被引用的项目DLL的路径
  • ,并重新添加了项目参考。
  • 在编辑文件时,Intellisense能够找到参考,但是当构建控制台时,输出显示错误。
  • 清理解决方案的
  • 建议在线清理临时文件夹和 appdata \ local \ Microsoft \ visualStudio \ 17.x \ componentModelCache for My用户帐户,但

所有这些都没有帮助。任何有关研究或尝试/洞悉问题的指南都将不胜感激!

谢谢

- 奥斯汀

编辑1(7/5/2022) 错误列表image

当我从错误列表中单击它们时,错误似乎会自行解决(查看之后文件发生错误的位置,几秒钟后错误消失,从错误列表中删除该错误,并删除红色Squiggle下划线)。但是,由于尝试构建测试项目时,错误实际上并未解决,因为仍然存在相同的参考错误。

例如,step.entities是解决方案中的一个项目,该项目由测试项目引用。但是,测试项目找不到推荐实体项目。

I'm currently running into an issue (on Visual Studio 2022) where the test project within my solution is referencing a few other projects in my solution; however, trying to build the test project results in errors for these project references. Even more interesting is that this test project used to be working fine.

So far I've:

  • Double checked the pathing of the project dll's being referenced
  • Removed and re-added the project references.
  • Editing the file, Intellisense is able to find the references, but when building the console output shows errors.
  • Cleaned the solution
  • Seen recommendations online of clearing the Temp folder and AppData\Local\Microsoft\VisualStudio\17.x\ComponentModelCache for my user account and have done so

None of this has helped. Any guidance on what to research or things to try/insight to the problem would be much appreciated!

Thank you

-Austin

EDIT 1 (7/5/2022)
Error List Image

The error seem to resolve themselves when I click on them from the Error Lists (after viewing the place in the file where the reference error is occurring, the error disappears after a few seconds, removing it from the Error List and also the removing the red squiggle underline). However, the error does not actually resolve as there are still the same reference errors when trying to Build the test project.

For example, STEP.Entities is a project in the solution that is referenced by the test project. However, the test project can't find the referred Entities project.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

在巴黎塔顶看东京樱花 2025-02-19 07:51:50

我意识到,该问题是由解决方案其他项目中使用的软件包引起的,它针对的是.NET版本与测试项目中的相同软件包。

  • (首先,为了确定这一点,我去了工具>项目和解决方案>构建和运行> select msbuild project build build build build dermotie diagnostic。 )。

具体来说,我的测试项目中的许多包装都针对.NET v 4.8,而不是其他项目中的包裹针对的v4.7.2,而测试项目本身和针对v4.7.2的其他项目。我将测试项目更新为Target v4.8,并且可以找到所有工作/参考。

I realized the issue was caused by packages used in the other projects of the solution were targeting different .NET versions than the same packages within the Test project.

  • (Firstly, to determine this I went to Tools > Projects and Solutions > Build and Run > select MSBuild Project Build Verbosity as Diagnostic. (I believe this generates more a detailed report of the status to the Output Console when building projects)).

Specifically, a lot of these packages in my test project were targeting .NET v 4.8 as opposed to v4.7.2 being targeted by packages in the other projects, and the Test project itself and other projects targeting v4.7.2. I updated my Test project to target v4.8 and everything works/references can be found.

撞了怀 2025-02-19 07:51:50

最近,我有一个来自Github的项目遇到了这个问题,我最好的Subention是尝试检查您正在使用的版本,并可能选择较旧版本的所述参考文献。
我花了一段时间才完成它,但奏效了。

I've had this problem recently with a project from GitHub, my best sugestion is to try checking the version you are using and maybe select an older version of the said references.
It took me a while to get it done but it worked.

末蓝 2025-02-19 07:51:50

我认为我在我的驱动器的根部中使用以下global.json

c:\ global.json

{
  "sdk": {
    "version": "6.0.300",
    "rollForward": "latestFeature",
    "allowPrerelease": false
  }
}

或您的解决方案中可能有global.json ,具有不存在的.NET SDK版本...

列出计算机上安装的所有.NET SDK,然后运行

dotnet --list-sdks

并选择正确的版本。

I think I worked around this with following global.json in the root of my drive:

C:\global.json

{
  "sdk": {
    "version": "6.0.300",
    "rollForward": "latestFeature",
    "allowPrerelease": false
  }
}

Or there might be a global.json in your solution somewhere, with a .NET SDK version that doesn't exist...

To list all installed .NET sdks on your computer, run

dotnet --list-sdks

and pick the correct version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文