适用于便携式库的Nuget包的.Net 2015参考带有黄色三角形 [英] .Net 2015 References with yellow triangle for Nuget packages on portable libraries

查看:80
本文介绍了适用于便携式库的Nuget包的.Net 2015参考带有黄色三角形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道之前曾有人问过这个问题,但是没有一个建议的解决方案对我有用,因此我将再次提出该问题,并希望获得新的建议.我读过的一些文章:

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参考 黄色三角形中的感叹号图标(在解决方案资源管理器中)

我的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 Framework 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>..\..\..\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

C:\xxxx\xxxxxx\xxxxx-xxxxxxx

因此以bouncycastle为例,并基于上述内容,我认为完整路径应如下所示:

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

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

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%.

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

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

and it provided a link to this article Diagnosing Project System Build Errors

在按照提供的说明并检查了以designtime.log结尾的大量文件之后,我注意到所有文件都有一个FAIL引用Nuget程序包,但是如上所述,我已从各种文件中删除了所有文件项目,所以我去重新检查了其中一个.csproj,这是我发现问题的地方!

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)!

实际上有两个问题:

  1. NugetMicrosoft.BCL.Build参考未正确删除!

重新添加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="..\..\..\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,它似乎仍保留在项目中.

As you can see the first line i.e. <Import Project="..\..\..\packages\Microsoft.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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆