Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 References with yellow triangle 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)

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 (classic)

What I've tried/done so far:

  • Remove Nuget package references manually from all projects.
  • Check each .csproj and made sure that the references were indeed removed.
  • Delete the packages folder in the root of my solution
  • Tried to re-installed all packages via the console manager. No error yet yellow triangle is still displayed.
  • Tried to re-installed all packages via the Nuget manager. No error yet yellow triangle is still displayed.

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> 

My physcial project path is:

C:\xxxx\xxxxxx\xxxxx-xxxxxxx

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

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.

Has anyone got any other suggestions?

like image 817
Thierry Avatar asked May 13 '16 11:05

Thierry


People also ask

How do I update NuGet package references?

Update a package. In Solution Explorer, right-click either References or the desired project, and select Manage NuGet Packages.... (In web site projects, right-click the Bin folder.) Select the Updates tab to see packages that have available updates from the selected package sources.

What is the .NuGet folder?

nuget folder is used as a cache for packages downloaded to speed up project restore and compilation. It can safely be removed.


2 Answers

If you've received no output errors during install and there are no Warnings on build/rebuild. Simply:

  1. Restart Visual Studio
like image 123
pim Avatar answered Sep 18 '22 07:09

pim


I figured out what the problem was!

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

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

There are actually 2 problems:

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

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

Below is an example of the fault:

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

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.

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\` 

and kept this one:

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

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.

like image 23
Thierry Avatar answered Sep 18 '22 07:09

Thierry