SuppressDependenciesWhenPacking is not working when we set this property for tfm net6.0-windows.
I did a little investigation and it seems like it works when we specify the this tfm as net6.0-windows7.0.
i tested this by adding this to the project.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0;net5.0-Windows;net5.0-unix99.0</TargetFrameworks>
<IsPackable>true</IsPackable>
</PropertyGroup>
<PropertyGroup>
<TargetPlatformSupported>true</TargetPlatformSupported>
<TargetPlatformVersionSupported>true</TargetPlatformVersionSupported>
<SuppressDependenciesWhenPacking Condition="'$(TargetFramework)' == 'net5.0-Windows'">true</SuppressDependenciesWhenPacking>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="C:\git\scratch\libA\libA.csproj" />
<PackageReference Include="System.Diagnostics.EventLog" Version="5.0.0" Condition="'$(TargetFramework)' != 'net5.0-unix99.0'" />
</ItemGroup>
</Project>
output nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>libB</id>
<version>1.0.0</version>
<authors>libB</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package Description</description>
<dependencies>
<group targetFramework="net5.0">
<dependency id="libA" version="1.0.0" exclude="Build,Analyzers" />
<dependency id="System.Diagnostics.EventLog" version="5.0.0" exclude="Build,Analyzers" />
</group>
<group targetFramework="net5.0-unix99.0">
<dependency id="libA" version="1.0.0" exclude="Build,Analyzers" />
</group>
<group targetFramework="net5.0-windows7.0">
<dependency id="libA" version="1.0.0" exclude="Build,Analyzers" />
<dependency id="System.Diagnostics.EventLog" version="5.0.0" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
<files>
<file src="C:\git\scratch\libB\bin\Debug\net5.0\libB.dll" target="lib\net5.0\libB.dll" />
<file src="C:\git\scratch\libB\bin\Debug\net5.0-unix99.0\libB.dll" target="lib\net5.0-unix99.0\libB.dll" />
<file src="C:\git\scratch\libB\bin\Debug\net5.0-windows\libB.dll" target="lib\net5.0-windows7.0\libB.dll" />
</files>
</package>
REquired nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>libB</id>
<version>1.0.0</version>
<authors>libB</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package Description</description>
<dependencies>
<group targetFramework="net5.0">
<dependency id="libA" version="1.0.0" exclude="Build,Analyzers" />
<dependency id="System.Diagnostics.EventLog" version="5.0.0" exclude="Build,Analyzers" />
</group>
<group targetFramework="net5.0-unix99.0">
<dependency id="libA" version="1.0.0" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
<files>
<file src="C:\git\scratch\libB\bin\Debug\net5.0\libB.dll" target="lib\net5.0\libB.dll" />
<file src="C:\git\scratch\libB\bin\Debug\net5.0-unix99.0\libB.dll" target="lib\net5.0-unix99.0\libB.dll" />
<file src="C:\git\scratch\libB\bin\Debug\net5.0-windows\libB.dll" target="lib\net5.0-windows7.0\libB.dll" />
</files>
</package>
The required nuspec can be obtained by adding
<ItemGroup>
<_FrameworksWithSuppressedDependencies Include="net5.0-windows7.0"/>
</ItemGroup>
to the csproj
cc @viktorHofer @safern @ericstj
@Anipik maybe you can provide a repro project and then describe what you'd expect the nuspec to look like vs what it actually looks like?
I added the customer project with net5.0 as target
Fixed in https://github.com/NuGet/NuGet.Client/commit/d6dc0502b45cee9857187f26f3b05860e13256d4.
Dup of https://github.com/NuGet/Home/issues/10097.
Unfortunately this did not make it into 5.0.100, so the fix will only flow into 5.0.200.
fyi @zkat