Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/NuGetizer.Tasks/NuGetizer.Inference.targets
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<Pack Condition="'$(PackDependencies)' == 'false'">false</Pack>
<PrivateAssets />
</ImplicitPackageReference>
<ReferenceCopyLocalPathsOutputGroupOutput>
<Facade>false</Facade>
<FrameworkFile>false</FrameworkFile>
<NuGetPackageId />
<Pack />
</ReferenceCopyLocalPathsOutputGroupOutput>
<ReferencePath>
<Facade>false</Facade>
<FrameworkFile>false</FrameworkFile>
Expand Down Expand Up @@ -373,11 +379,20 @@ Copyright (c) .NET Foundation. All rights reserved.

</Target>

<Target Name="_CollectPrimaryOutputDependencies" DependsOnTargets="BuildOnlySettings;RunResolvePackageDependencies;ResolveReferences" Returns="@(ImplicitPackageReference)">
<Target Name="_CollectPrimaryOutputDependencies" DependsOnTargets="ReferenceCopyLocalPathsOutputGroup;RunResolvePackageDependencies" Returns="@(ImplicitPackageReference)">
<Error Code="NG1003" Text="Centrally managed package versions is only supported when using the Microsoft.NET.Sdk."
Condition="'$(ManagePackageVersionsCentrally)' == 'true' and '$(UsingMicrosoftNETSdk)' != 'true'" />
<ItemGroup>
<_PrimaryOutputRelatedFile Include="@(ReferencePath);@(_ReferenceRelatedPaths)"
<!-- By adding the files in this order, we ensure that Distinct() will preserve this preference order.
We add them with identities that will find the duplicate files resolved from the same package id,
so we can de-duplicate using the given preference order. -->
<_CopyLocalReference Include="@(ReferenceCopyLocalPathsOutputGroupOutput->'%(NuGetPackageId)|%(Filename)%(Extension)')" OriginalItemSpec="%(Identity)" />
<_CopyLocalReference Include="@(ReferencePath->'%(NuGetPackageId)|%(Filename)%(Extension)')" OriginalItemSpec="%(Identity)" />
<_CopyLocalReference Include="@(_ReferenceRelatedPaths->'%(NuGetPackageId)|%(Filename)%(Extension)')" OriginalItemSpec="%(Identity)" />
<_CopyLocalReferenceDistinct Include="@(_CopyLocalReference->Distinct())" />
<_ReferenceCopyLocalPaths Include="@(_CopyLocalReferenceDistinct->'%(OriginalItemSpec)')" />

<_PrimaryOutputRelatedFile Include="@(_ReferenceCopyLocalPaths)"
Condition="'%(NuGetPackageId)' != 'NETStandard.Library' and
'%(Facade)' != 'true' and
'%(FrameworkFile)' != 'true' and
Expand Down
33 changes: 33 additions & 0 deletions src/NuGetizer.Tests/InlineProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -714,5 +714,38 @@ public void when_multi_targeting_packing_transitive_dependency_then_retargets_to
TargetFramework = "netstandard2.0",
}));
}

[Fact]
public void when_packing_with_refs_then_includes_runtime_libs_for_private()
{
var result = Builder.BuildProject(
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageId>TestNuGetizer</PackageId>
<LangVersion>Latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Buffers" Version="4.5.1" PrivateAssets="all" />
<PackageReference Include="System.Memory" Version="4.5.5" PrivateAssets="all" />
</ItemGroup>
</Project>
""", output: output);

result.AssertSuccess(output);

Assert.Contains(result.Items, item => item.Matches(new
{
PathInPackage = "lib/net461/System.Buffers.dll",
}));
Assert.Contains(result.Items, item => item.Matches(new
{
PathInPackage = "lib/net461/System.Memory.dll",
}));
}
}
}
2 changes: 1 addition & 1 deletion src/NuGetizer.Tests/NuGetizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);Scenarios\**\*</DefaultItemExcludes>
<LangVersion>Preview</LangVersion>
<LangVersion>Latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public void when_getting_package_contents_then_contains_private_assets_as_primar
{
PackFolder = PackFolderKind.Lib,
Filename = "Mono.Options",
NuGetSourceType = "Package",
NuGetPackageId = "Mono.Options",
}));
}
Expand All @@ -53,7 +52,6 @@ public void when_getting_package_contents_then_contains_private_lib_assets_as_pr
{
PackFolder = PackFolderKind.Lib,
Filename = "Newtonsoft.Json",
NuGetSourceType = "Package",
NuGetPackageId = "Newtonsoft.Json",
}));
}
Expand All @@ -77,7 +75,6 @@ public void when_getting_package_contents_then_contains_dependency_for_non_priva
{
PackFolder = PackFolderKind.Lib,
Filename = "xunit",
NuGetSourceType = "Package",
NuGetPackageId = "xunit",
}));
}
Expand Down