Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Why must I include '-windows' in a netcoreapp6.0 when consuming a netstandard2.0 compatible package?

$
0
0

When upgrading some unit test projects to netcoreapp6.0, I noticed the NETSDK1136 error popping up, asking me: "The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing projects or packages that do so."

I checked all the dependencies, and found Rg.Plugins.Popup (2.1.0) to be the culprit.

However, the possible platforms of this nuget package are:

  • .NETCoreApp v3.1
  • .NETStandard v2.0
  • etc... (net framework, xamarin ios, monoandroid)

Given that netcoreapp6.0 implements netstandard2.1, which is a superset of netstandard2.0, I'd expect the compiler not whine about adding 'Windows'. Moreover, if I consume package SkiaSharp.Views.Forms 2.88.0 (which has a lot of similar platforms as Rg.Plugins.Popup), it uses the netstandard2.0 version of that package.

My first question would be: Why does this happen? Why isn't netstandard2.0 not simply targetted?

I tried a few things

  • I added <AssetTargetFallback>$(AssetTargetFallback);netstandard2.0</AssetTargetFallback> to the csproj, but to no avail
  • I removed the PackageReference and referenced the netstandard2.0 dll directly:<Reference Include="Rg.Plugins.Popup"><HintPath>C:\Users\MyUser\.nuget\packages\rg.plugins.popup\2.1.0\lib\netstandard2.0\Rg.Plugins.Popup.dll</HintPath></Reference> which removes the error, but is harder to update and such.
  • I read somewhere else on stackoverflow that you can do the above better by doing it like below, but that didn't remove the error either.
<ItemGroup><PackageReference Include="Rg.Plugins.Popup" Version="2.1.0" ExcludeAssets="Compile" GeneratePathProperty="true" /><Reference Include="Rg.Plugins.Popup" ><HintPath>$(PkgRg_Plugins_Popup)\lib\netstandard2.0\Rg.Plugins.Popup.dll</HintPath><!-- also tried without the \ trailing $(PkgRg_Plugins_Popup), but that doesn't work either --></Reference></ItemGroup>

Second question: Why doesn't the third approach work? Given this, the microsoft docs, and other StackOverflow posts, I'd expect this to work.

Below the csproj, so you can see it's as plain as possible:

<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>netcoreapp6.0</TargetFramework></PropertyGroup><ItemGroup><PackageReference Include="Rg.Plugins.Popup" Version="2.1.0" /></ItemGroup></Project>

Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>