31

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?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Thierry
  • 6,142
  • 13
  • 66
  • 117
  • If you select the libraries with the exclamation and check the properties pane it tells you anything useful? – Gusman May 13 '16 at 11:36
  • Look in the Error List window, some odds that the IntelliSense parser has a useful warning. – Hans Passant May 13 '16 at 11:58
  • @Gusman - Not a thing but I did go an compare it to my working project and strangely, in the working project it has the "Copy Local" and "Specific Version" set to true while in the non-working project, both of these properties are set to false. Also the "Runtime Version" and "Version" properties are set in the working copy, but not in the other one! I'll try to change the "Copy Local" and "Specific Version" to true, but I think there's more to it than that to be honest. – Thierry May 13 '16 at 11:58
  • Hmmm, that's then because it can't be loaded at all. As the referenced article states it usually is because the wrong target framework is selected. I see you checked it, but it would be worth it to test with all the available possibilities, just take one of the projects with the problem and test changing the framework version and PCL profile, that's your best bet. – Gusman May 13 '16 at 12:02
  • @Gusman I had my warnings turned off and when I checked them I spotted the following: "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.". I assume it has something to do with this and I'm currently reading more about it on https://github.com/dotnet/roslyn/wiki/Diagnosing-Project-System-Build-Errors. If not, I'll try what you suggested. – Thierry May 13 '16 at 12:13
  • @Gusman I figured it out! I'll post the answer now. – Thierry May 13 '16 at 13:55
  • Hmmm, an small question, did you removed the bcl package from references or from the nuget package manager? – Gusman May 13 '16 at 15:05
  • @Gusman All my Nuget packages including the bcl were removed via the Nuget package manager and also tried it via the Nuget console. Very odd alright! – Thierry May 13 '16 at 15:20
  • Well, yes, really odd, glad you got it working! – Gusman May 13 '16 at 15:20

8 Answers8

66

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

  1. Restart Visual Studio
pim
  • 12,019
  • 6
  • 66
  • 69
  • 19
    you're fricken kidding me... I had been chasing core 1.0 issues down all afternoon and when I restarted VS, all my refs came in just fine... – Rikon Oct 17 '17 at 18:04
  • 4
    @Rikon sorry to hear about your luck! can't count the numbers of times I've been in the same boat... couple habits I've gotten myself into recently is closing tabs and environments somewhat frequently. Prevents head scratchers like this and I find my machine runs a little better. – pim Oct 17 '17 at 18:27
  • 2
    just helped me with BuildBundlerMinifier package – Sergi0 Dec 07 '17 at 00:58
  • @Sergi0 Same. And also JwtBearer... restarting the ide worked. I love my Chrome Tabs and apps, @pimbrouwers! Please don't take them away! :-( – adamgede Jan 23 '18 at 18:52
  • 1
    @adamgede So glad to hear this helped you. I should've been more clear in my comments. When I say "tabs" I mean VS Tabs. When I say "environments" I mean the various instances of VS I have open. – pim Jan 23 '18 at 19:06
  • This worked after ensuring all of my project's .NET Framework versions were the same, Nuget packages were reinstalled, and finally - after much head scratching, simply restarting Visual Studio. If you're using something like Resharper, clear the caches out too. – Lunster Jul 03 '18 at 09:16
  • Such a simple solution to an annoying problem. – Heike Jan 10 '19 at 19:41
  • How does this work?! Agh, so annoying - but thank you so much for this. – Ben Sampica Mar 26 '19 at 20:13
  • @BenSampica it's really frustrating. If you look at the output window, you might get more insights as to what might be failing. It also might be that restarting VS resets the symbol cache (though this is a complete guess). – pim Mar 26 '19 at 20:35
  • Ya know...after 20 years of Visual Studio...you would think "little things" like this would be worked-out (by now) – Prisoner ZERO May 26 '19 at 14:41
23

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.

gonzobrains
  • 7,856
  • 14
  • 81
  • 132
Thierry
  • 6,142
  • 13
  • 66
  • 117
8

I faced the same issue on a solution in vs2017 with 2 projects for framework DotNetCoreApp 1.1. All my packages showed the exclamation sign/yellow triangles. Once i ran vs2017 as an administrator, it was resolved.

R. van Diesen
  • 829
  • 8
  • 10
2

I had a same issue when I cloned a project to my laptop from GitHub. There are yellow triangles displaying on my EntityFramework and AspNet.Identity as well. What I did to solve the issue in my case was to remove the packages folder (which contains Nuget packages) and restore packages once I opened the project. As a result, those warnings were switched off after I restarted VS2017.

Jason Ho
  • 21
  • 1
2

You could check my answer on relative topic here, because the answer of this topic it's a dangerous way to do things specially if you have a project on Production ambient: https://stackoverflow.com/a/59704420/7969733

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://learn.microsoft.com/es-es/nuget/consume-packages/package-restore#restore-packages-automatically-using-visual-studio

But just cleaning the cache solve all the problems

sgrysoft
  • 588
  • 7
  • 14
1

I know it's an old post but recently I have been suffering from that warning error after changing my lap. I did a get with TFS (in visual studio 2017) and suddenly all my references had a warning icon. What I found working for me is that: go to object browser then select the combo box "All Components" and finally select your framework. For me, it worked like a charmed.

Resolve warning references error

Nehoss
  • 33
  • 5
1

If someone comes here by having this issue after the last release of .net 6, this is how to solve it, I know than this is a old post, but this problem is recurrent:

https://stackoverflow.com/a/72778756/7969733

sgrysoft
  • 588
  • 7
  • 14
0
  1. Copy your project files to another folder
  2. Delete folder with the project of the solution
  3. Create new project with same name
  4. Copy files from step 1 to the new project
  5. Restore packages
shop350
  • 198
  • 1
  • 6