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

Prevent installing my NuGet package to project with unsupported target framrwork

$
0
0

My NuGet Package targets .NET Standard 2.0 and .NET Framework 4.0.

The .nuspec looks like:

<?xml version="1.0"?><package><metadata>    ...<dependencies><group targetFramework=".NETStandard2.0"/><group targetFramework=".NETFramework4.0"/></dependencies></metadata><files><file src="...\net40\WinSCPnet.dll" target="lib\net40"/><file src="...\netstandard2.0\WinSCPnet.dll" target="lib\netstandard2.0"/></files></package>

The assembly included in the package has:

<TargetFrameworks>net40;netstandard2.0</TargetFrameworks>

But this does not prevent the package from being installed to projects that target different frameworks. For example it can be installed to project targeting .NET Framework 3.5. Obviously it does not work then, as there's no 3.5 version of the assembly.

I assume it should be somehow possible to prevent installing the package to projects targeting unsupported frameworks. For example question NuGet package not installing in .NET Framework shows that certain packaged failed to install for this very reason. How do I achieve that in my package?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



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