From 30278e4a01824121593073298902a8670e5f9115 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 17:01:46 +0000 Subject: [PATCH 1/2] Add support for packing reference assemblies Co-authored-by: kzu <169707+kzu@users.noreply.github.com> --- .../NuGetizer.Inference.targets | 11 ++ src/NuGetizer.Tasks/NuGetizer.props | 1 + src/NuGetizer.Tests/InlineProjectTests.cs | 143 ++++++++++++++++++ 3 files changed, 155 insertions(+) diff --git a/src/NuGetizer.Tasks/NuGetizer.Inference.targets b/src/NuGetizer.Tasks/NuGetizer.Inference.targets index 91eb7e7f..a5badace 100644 --- a/src/NuGetizer.Tasks/NuGetizer.Inference.targets +++ b/src/NuGetizer.Tasks/NuGetizer.Inference.targets @@ -36,6 +36,9 @@ Copyright (c) .NET Foundation. All rights reserved. true + + true + false @@ -402,6 +405,14 @@ Copyright (c) .NET Foundation. All rights reserved. <_InferredPackageFile Include="@(_InferredProjectOutput -> Distinct())" /> + + + <_InferredPackageFile Include="$(TargetRefPath)"> + Ref + true + + + <_InferredPackageFile Include="@(ResourceCopyLocalItems)" diff --git a/src/NuGetizer.Tasks/NuGetizer.props b/src/NuGetizer.Tasks/NuGetizer.props index 83f93078..43ee1399 100644 --- a/src/NuGetizer.Tasks/NuGetizer.props +++ b/src/NuGetizer.Tasks/NuGetizer.props @@ -134,6 +134,7 @@ Copyright (c) .NET Foundation. All rights reserved. ref + true analyzers diff --git a/src/NuGetizer.Tests/InlineProjectTests.cs b/src/NuGetizer.Tests/InlineProjectTests.cs index 6d43a63f..8e6eb499 100644 --- a/src/NuGetizer.Tests/InlineProjectTests.cs +++ b/src/NuGetizer.Tests/InlineProjectTests.cs @@ -1097,5 +1097,148 @@ public void when_dependency_is_development_dependency_then_can_explicitly_pack_i Assert.Equal("ThisAssembly.Constants", manifest.Metadata.DependencyGroups.First().Packages.First().Id); } } + + [Fact] + public void when_produce_reference_assembly_then_includes_ref_assembly() + { + var result = Builder.BuildProject( + """ + + + net8.0 + true + + + """, output: output); + + result.AssertSuccess(output); + + // Should have the main assembly in lib + Assert.Contains(result.Items, item => item.Matches(new + { + Extension = ".dll", + PackFolder = PackFolderKind.Lib + })); + + // Should also have the reference assembly in ref + Assert.Contains(result.Items, item => item.Matches(new + { + Extension = ".dll", + PackFolder = PackFolderKind.Ref + })); + } + + [Fact] + public void when_produce_reference_assembly_false_then_does_not_include_ref_assembly() + { + var result = Builder.BuildProject( + """ + + + net8.0 + false + + + """, output: output); + + result.AssertSuccess(output); + + // Should have the main assembly in lib + Assert.Contains(result.Items, item => item.Matches(new + { + Extension = ".dll", + PackFolder = PackFolderKind.Lib + })); + + // Should NOT have a reference assembly in ref + Assert.DoesNotContain(result.Items, item => item.Matches(new + { + PackFolder = PackFolderKind.Ref + })); + } + + [Fact] + public void when_produce_reference_assembly_but_pack_build_output_false_then_does_not_include_ref_assembly() + { + var result = Builder.BuildProject( + """ + + + net8.0 + true + false + + + """, output: output); + + result.AssertSuccess(output); + + // Should NOT have the main assembly in lib + Assert.DoesNotContain(result.Items, item => item.Matches(new + { + Extension = ".dll", + PackFolder = PackFolderKind.Lib + })); + + // Should NOT have a reference assembly in ref either + Assert.DoesNotContain(result.Items, item => item.Matches(new + { + PackFolder = PackFolderKind.Ref + })); + } + + [Fact] + public void when_produce_reference_assembly_can_opt_out_with_pack_ref_assembly_false() + { + var result = Builder.BuildProject( + """ + + + net8.0 + true + false + + + """, output: output); + + result.AssertSuccess(output); + + // Should have the main assembly in lib + Assert.Contains(result.Items, item => item.Matches(new + { + Extension = ".dll", + PackFolder = PackFolderKind.Lib + })); + + // Should NOT have a reference assembly in ref + Assert.DoesNotContain(result.Items, item => item.Matches(new + { + PackFolder = PackFolderKind.Ref + })); + } + + [Fact] + public void when_produce_reference_assembly_then_ref_assembly_is_framework_specific() + { + var result = Builder.BuildProject( + """ + + + net8.0 + true + true + + + """, output: output); + + result.AssertSuccess(output); + + // The ref assembly should have a package path that includes the TFM + Assert.Contains(result.Items, item => item.Matches(new + { + PackFolder = PackFolderKind.Ref, + PackagePath = "ref/net8.0/scenario.dll" + })); + } } } From 872f56a1c0774d97724a2bab5160b8d940135662 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 15 Jan 2026 20:28:10 +0000 Subject: [PATCH 2/2] Document PackRefAssembly property in readme Co-authored-by: kzu <169707+kzu@users.noreply.github.com> --- readme.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index e8ca9bfb..85f2b2ad 100644 --- a/readme.md +++ b/readme.md @@ -227,6 +227,7 @@ When an item specifies *FrameworkSpecific=true*, the project's target framework |------------------|-------------------| | content (*) | true | | lib | true | +| ref | true | | dependency (**) | true | | frameworkReference (**) | true | | build | false | @@ -236,7 +237,7 @@ When an item specifies *FrameworkSpecific=true*, the project's target framework \** *dependency* and *frameworkReference* are pseudo folders containing the package references and framework (`` items, which are ultimately evaluated together with the metadata for the individual items. These make the package inference candidates. You can also provide an exclude expression for that evaluation so that certain items are excluded by default, even if every other item of the same type is included. For example, to pack all `Content` items, except those in the `docs` folder, you can simply update the inference item like so: