.Net 2015 带有黄色三角形的参考资料,用于可移植库上的 Nuget 包

.Net 2015 References with yellow triangle for Nuget packages on portable libraries

我知道之前有人问过这个问题,但是 none 的建议解决方案对我有用,所以我会再问一次,希望能得到新的建议。我读过的一些文章:

Why do I get a warning icon when I add a reference to an MEF plugin project? The exclamation mark in the yellow triangle icon (inside Solution Explorer)

我的 5 个可移植库肯定都针对相同的框架(我检查并重新检查,因为这是其中一个建议!):

到目前为止我 tried/done:

这是我的一个便携式 class 库的部分:

<ItemGroup>
    <Reference Include="crypto">
      <HintPath>..\..\..\packages\Portable.BouncyCastle.1.8.1\lib\portable-
        net4+sl5+wp8+win8+wpa81+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10
        \crypto.dll
      </HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
  <HintPath>..\..\..\packages\Newtonsoft.Json.8.0.3\lib\portable-
      net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll
  </HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="System.Net.Http">
  <HintPath>..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\portable-
      net40+sl4+win8+wp71+wpa81\System.Net.Http.dll
  </HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Extensions">
  <HintPath>..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\portable-
      net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll
  </HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Primitives">
  <HintPath>..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\portable-
      net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll
  </HintPath>
  <Private>True</Private>
</Reference>

我的物理项目路径是:

C:\xxxx\xxxxxx\xxxxx-xxxxxxx

所以以 bouncycastle 为例,基于以上内容,我假设完整路径如下所示:

C:\xxxx\xxxxxx\xxxxx-xxxxxxx\packages\Portable.BouncyCastle.1.8.1\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10\crypto.dll

这似乎只是我的可移植库的问题,因为我已经在我的 uwp 解决方案上重新安装了所有 Nuget 包,它们都按预期工作。令人沮丧的是,我的项目仍然位于其原始位置,但运行良好。我已经卸载并重新安装了软件包,一切都 100% 正常工作。

还有其他建议吗?

我知道问题出在哪里了!

正如@Gusman 提到的,我关闭了警告。打开它们后,我的便携式项目显示如下:

Warning: IDE0006 - Error encountered while loading the project. Some project
features, such as full solution analysis for the failed project and projects
that depend on it, have been disabled

它为这篇文章提供了 link Diagnosing Project System Build Errors

按照提供的说明并检查以 designtime.log 结尾的众多文件后,我注意到所有文件都有一个 FAIL 引用 Nuget 包,但如前所述,我已经从我的各种项目中删除了所有这些,所以我去重新检查其中一个的 .csproj,这是我发现问题的时候!

实际上有2个问题:

  1. NugetMicrosoft.BCL.Build 引用未正确删除!!

  2. 重新添加Microsoft.BCL.Build Nuget包时,在.csproj

  3. 中没有正确设置路径

故障示例如下​​:

<Import Project="..\..\..\packages\Microsoft.Bcl.Build.1.0.21
       \build\Microsoft.Bcl.Build.targets" Condition="Exists
       ('..\..\..\packages\Microsoft.Bcl.Build.1.0.21
       \build\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\
        Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format
        ('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21
        \build\Microsoft.Bcl.Build.targets'))" />
    <Error Condition="!Exists('..\..\..\packages\Microsoft.Bcl.Build.1.0.21\build\
        Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format
        ('$(ErrorText)', '..\..\..\packages\Microsoft.Bcl.Build.1.0.21\
        build\Microsoft.Bcl.Build.targets'))" />
</Target>

如您所见,第一行即 <Import Project="..\..\..\packages\Microsoft.Bcl.Build.1.0.21> 不应该存在,但它似乎仍保留在项目中,即使 Microsoft.BCL.Build 已被删除。

如果您需要它,请保留它并修复第二个条目,因为这是我所做的。如您所见,有两个条目正在检查 Microsoft.BCL.Build Nuget 包。就我而言,我只是删除了第一个:

`<Error Condition="!Exists('..\packages\`

并保留了这个:

`<Error Condition="!Exists('..\..\..\packages\`

编辑完 .csproj 后,我在我的解决方案中重新加载了项目,不仅 Microsoft.BCL.Build 问题得到解决,还解决了所有其他标有黄色的 Nuget 依赖项三角形。

我一天的大部分时间都浪费在这上面了,但希望这会对其他人有所帮助。

  1. 将您的项目文件复制到另一个文件夹
  2. 删除包含解决方案项目的文件夹
  3. 创建同名新项目
  4. 将步骤 1 中的文件复制到新项目
  5. 恢复包

我在 vs2017 的解决方案中遇到了同样的问题,其中有 2 个项目用于框架 DotNetCoreApp 1.1。 所有 我的包裹显示感叹号 sign/yellow 三角形。我曾经运行 vs2017以管理员身份解决过

如果您在安装期间没有收到任何输出错误并且 build/rebuild 上没有 警告。只需:

  1. Restart Visual Studio

我从 GitHub 将项目克隆到我的笔记本电脑时遇到了同样的问题。我的 EntityFramework 和 AspNet.Identity 上也显示黄色三角形。在我的案例中,我为解决这个问题所做的是删除包文件夹(其中包含 Nuget 包)并在我打开项目后恢复包。结果,在我重新启动 VS2017 后,这些警告被关闭了。

我知道这是一个旧的 post 但最近我在换圈后一直遇到警告错误。我做了一个 TFS(在 visual studio 2017 年),突然间我所有的参考都有一个警告图标。我发现对我有用的是:转到对象浏览器,然后 select 组合框 "All Components",最后 select 你的框架。对我来说,它就像被迷住了一样。

你可以在这里查看我对相关主题的回答,因为如果你有一个关于生产环境的项目,这个主题的答案是一种危险的做事方式:

Just for documentation purpose for new person with this issue try this and you will rememberme :D

If you go to: Tools > NuGet Administrator > Configurations. and you have "Allow nuget...." and "automatically check...." cheked.

The only thing than you have to do is click con the button "Clear All NuGet Cache(s)"

That's it, you don't have to edit manual thinks than can be dangerous, believe me, I use to need to done some of the steps than describe here a lot of time, and try more than 5 steps of the oficial microsoft documentation for that issue you could check it here: https://docs.microsoft.com/es-es/nuget/consume-packages/package-restore#restore-packages-automatically-using-visual-studio

But just cleaning the cache solve all the problems