.Net 2015 对便携式库上 Nuget 包的黄色三角形参考

.Net 2015 References with yellow triangle for Nuget packages on portable libraries(.Net 2015 对便携式库上 Nuget 包的黄色三角形参考)
本文介绍了.Net 2015 对便携式库上 Nuget 包的黄色三角形参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I know the question has been asked before but none of the suggested resolutions are working for me so I'm going to ask it again and hopefully get new suggestions. Some of the articles I've read:

VS .Net 引用带有黄色三角形为什么我在添加对 MEF 插件项目的引用时会收到警告图标?黄色三角形中的感叹号图标(在解决方案资源管理器中)

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

My 5 portable libraries are definitely all targeting the same frameworks (I've checked and re-checked as this was one of the suggestions!):

  • .NET 框架 4.5
  • ASP.NET Core 1.0
  • Windows Phone 8
  • Windows Phone 8.1
  • Windows Phone Silverlight 8
  • Xamarin.Android
  • Xamarin.iOS
  • Xamarin.iOS(经典)

到目前为止我已经尝试/做了什么:

What I've tried/done so far:

  • 从所有项目中手动删除 Nuget 包引用.
  • 检查每个 .csproj 并确保确实删除了引用.
  • 删除我的解决方案根目录中的 packages 文件夹
  • 尝试通过控制台管理器重新安装所有软件包.没有错误,但黄色三角形仍然显示.
  • 尝试通过 Nuget 管理器重新安装所有软件包.没有错误,但黄色三角形仍然显示.

这是我的可移植类库之一的部分:

Here is the section of one of my portable class library:

<ItemGroup>
    <Reference Include="crypto">
      <HintPath>......packagesPortable.BouncyCastle.1.8.1libportable-
        net4+sl5+wp8+win8+wpa81+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10
        crypto.dll
      </HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
  <HintPath>......packagesNewtonsoft.Json.8.0.3libportable-
      net40+sl5+wp80+win8+wpa81Newtonsoft.Json.dll
  </HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="System.Net.Http">
  <HintPath>......packagesMicrosoft.Net.Http.2.2.29libportable-
      net40+sl4+win8+wp71+wpa81System.Net.Http.dll
  </HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Extensions">
  <HintPath>......packagesMicrosoft.Net.Http.2.2.29libportable-
      net40+sl4+win8+wp71+wpa81System.Net.Http.Extensions.dll
  </HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Primitives">
  <HintPath>......packagesMicrosoft.Net.Http.2.2.29libportable-
      net40+sl4+win8+wp71+wpa81System.Net.Http.Primitives.dll
  </HintPath>
  <Private>True</Private>
</Reference>

我的物理项目路径是:

C:xxxxxxxxxxxxxxx-xxxxxxx

C:xxxxxxxxxxxxxxx-xxxxxxx

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

so taking bouncycastle as an example and based on the above, I assume the full path would look like this:

C:xxxxxxxxxxxxxxx-xxxxxxxpackagesPortable.BouncyCastle.1.8.1libportable-net4+sl5+wp8+win8+wpa81+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10crypto.dll

C:xxxxxxxxxxxxxxx-xxxxxxxpackagesPortable.BouncyCastle.1.8.1libportable-net4+sl5+wp8+win8+wpa81+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10crypto.dll

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

This seems to be a problem only on my portable libraries as I've re-install all the Nuget packages on my uwp solution and they all worked as expected. The frustrating part is that my project which is still located in it's original location is working perfectly well. I've uninstalled the packages and re-installed them and everything is 100% working as expected.

还有人有其他建议吗?

推荐答案

我知道是什么问题了!

正如@Gusman 所说,我已关闭警告.打开它们后,我的便携式项目会显示以下内容:

As mentioned to @Gusman I had my warning switch off. Once I turned them on, I got the following displayed for my portable projects:

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

它提供了本文的链接诊断项目系统构建错误

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

After following the instructions provided and inspecting the numerous files ending in designtime.log, I noticed that all of them had a FAIL referring to a Nuget package but as mentioned, I had removed all of them from my various project, so I went to re-check the .csproj from one of them and this is when I spotted the problem(s)!

其实有2个问题:

  1. NugetMicrosoft.BCL.Build 参考没有被正确删除!!

  1. The Microsoft.BCL.Build reference for Nuget does not get remove properly!!

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

When re-adding Microsoft.BCL.Build Nuget package, it does not set the path correctly in the .csproj

以下是故障示例:

<Import Project="......packagesMicrosoft.Bcl.Build.1.0.21
       uildMicrosoft.Bcl.Build.targets" Condition="Exists
       ('......packagesMicrosoft.Bcl.Build.1.0.21
       uildMicrosoft.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('..packagesMicrosoft.Bcl.Build.1.0.21uild
        Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format
        ('$(ErrorText)', '..packagesMicrosoft.Bcl.Build.1.0.21
        uildMicrosoft.Bcl.Build.targets'))" />
    <Error Condition="!Exists('......packagesMicrosoft.Bcl.Build.1.0.21uild
        Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format
        ('$(ErrorText)', '......packagesMicrosoft.Bcl.Build.1.0.21
        buildMicrosoft.Bcl.Build.targets'))" />
</Target>

正如你所看到的第一行,即 <Import Project="......packagesMicrosoft.Bcl.Build.1.0.21> 不应该在那里并且然而,即使 Microsoft.BCL.Build 已被删除,它似乎仍保留在项目中.

As you can see the first line i.e. <Import Project="......packagesMicrosoft.Bcl.Build.1.0.21> should not be there and yet it appears to remain in the project even though Microsoft.BCL.Build has been removed.

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

If you need it leave it and fix the second entry as this is what I did. As you can see there are two entries checking for the Microsoft.BCL.Build Nuget package. In my case, I simply removed the first one:

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

并保留这个:

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

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

Once I finished editing the .csproj, I reloaded the project in my solution and not only was the Microsoft.BCL.Build issue resolved, it also resolved all the other Nuget dependencies that were marked with the yellow triangle.

浪费了我一天的大部分时间,但希望这对其他人有所帮助.

Wasted most of my day on this, but hopefully this will help others.

这篇关于.Net 2015 对便携式库上 Nuget 包的黄色三角形参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)