title: Error installing dotnet tool package because "it is not compatible with net50"
body: <p>I can't understand what I'm doing wrong. I'm trying to install ElectronNET.CLI package (<a href="https://www.nuget.org/packages/ElectronNET.CLI" rel="nofollow noreferrer">https://www.nuget.org/packages/ElectronNET.CLI</a>) through windows cmd:</p>
  <pre><code>dotnet tool install ElectronNET.CLI --version 11.5.1
  </code></pre>
  <p>but I've got error message:</p>
  <pre><code>error NU1202: Package ElectronNET.CLI 11.5.1 is not compatible with net50
  (.NETFramework,Version=v5.0) / any. 
  Package ElectronNET.CLI 11.5.1 supports: net5.0 (.NETCoreApp,Version=v5.0) / any
  The tool package could not be restored.
  Tool 'electronnet.cli' failed to install. This failure may have been caused by:
  
  * You are attempting to install a preview release and did not use the --version
  option to specify the version.
  * A package by this name was found, but it was not a .NET tool.
  * The required NuGet feed cannot be accessed, perhaps because of an Internet con
  nection problem.
  * You mistyped the name of the tool.
  </code></pre>
  <p>My .csproj file:</p>
  <pre><code>&lt;Project Sdk=&quot;Microsoft.NET.Sdk.Web&quot;&gt;    
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;net5.0&lt;/TargetFramework&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include=&quot;ElectronNET.API&quot; Version=&quot;11.5.1&quot; /&gt;
    &lt;/ItemGroup&gt;    
  &lt;/Project&gt;
  </code></pre>
  <p>Also I've created <code>global.json</code> file to override my sdk's global version. Because the package I'm trying to install targets net5, and current project version is net5, but my global sdk version is .net6. global.json:</p>
  <pre><code>{
      &quot;sdk&quot;: {
          &quot;version&quot;: &quot;5.0.103&quot;
      }
  }
  </code></pre>
  <p>What are the reasons describing that nuget package manager thinks I'm using <strong>.net50 (.NET Framework)</strong> instead of <strong>.net5.0</strong>? How and where can I change this version?</p>
  <p>For instance, when I created another c# project with .netcore 3.1 version and ElectronNet API and CLI of 9.31.2 versions (that targets netcore 3.1), everything was installed and worked fine.</p>
  <p><strong>UPD:</strong> I updated nuget.exe using <code>nuget.exe update -self</code>, but the new version works the same way with the same error.</p>
  <p><strong>UPD2:</strong> Tried to instal cli tool through visual studio. The message is much more confusing:
  <a href="https://i.stack.imgur.com/mh3zE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mh3zE.png" alt="enter image description here" /></a></p>
  <p><strong>UPD3:</strong> I removed net6 preview sdk from my computer, updated visual studio to 16.8.6 (and then did a &quot;repair&quot; of IDE through vs installer). I cleared nuget cache. Seems that cli tool that I tried to install now is installed, but now cmd <code>dotnet build</code> failed with the same message (<code>package ... is not compatible</code>) but now it says that already installed nuget package ElectronNET.API 11.5.1 is not compatible with net50! At the same time Visual Studio IDE successfully builds and runs this project (through IIS Express)! Only when I'm trying to use <code>dotnet build</code> then errors are miraculously appearing in the IDE:
  <a href="https://i.stack.imgur.com/fBRcX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fBRcX.png" alt="enter image description here" /></a></p>
  <p>Found similar problem <a href="https://developercommunity.visualstudio.com/t/error-msb4018-the-resolvepackagedependencies-task/1266042" rel="nofollow noreferrer">https://developercommunity.visualstudio.com/t/error-msb4018-the-resolvepackagedependencies-task/1266042</a>, but there are no solutions.</p>
  <p>Then I created a new clean blazor project based on .net5. Visual Studio successfully builds it, but <code>dotnet build</code> no. It says:</p>
  <pre><code>C:\Program Files\dotnet\sdk\5.0.103\Microsoft.Common.CurrentVersion.targets(1180,5): 
  error MSB3644: The reference assemblies for .NETFramework,Version=v5.0 were not found. 
  To resolve this, install the Developer Pack (SDK/Targeting Pack) for this
  framework version or retarget your application. You can download .NET Framework
  Developer Packs at https://aka.ms/msbuild/developerpacks
  </code></pre>
  <p>What a nice surprise. According to this post <a href="https://stackoverflow.com/questions/49268779/the-reference-assemblies-for-framework-netcore-version-v5-0-were-not-found">The reference assemblies for framework .NETCore, Version=v5.0 were not found</a> I've noticed that I have no .net5 folder neither in <code>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework</code> nor in <code>C:\Program Files\Reference Assemblies\Microsoft\Framework</code>.
  I reinstalled visual studio along with net5. Sdk appeared in <code>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v5.0</code>, but build error is the same. Obviously <code>dotnet</code> treats my <code>&lt;TargetFramework&gt;net5.0&lt;/TargetFramework&gt;</code> as net50
  (.NETFramework,Version=v5.0) and I don't know why.</p>