Skip to content

Commit 51f0e02

Browse files
committed
Make sure we can explicitly pack a privateassets/development dependency
As a package author, you might consume a development dependency for your own authoring, but also might want to take a dependency on it in your package. GitInfo is an example. We want to make sure we honor explicit Pack=true even if a package has PrivateAssets=all (which has different use cases too).
1 parent cacaa2d commit 51f0e02

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/NuGetizer.Tasks/NuGetizer.Inference.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ Copyright (c) .NET Foundation. All rights reserved.
401401
'$(PackAsPublish)' != 'true' and
402402
'%(PackageReference.Identity)' != 'NuGetizer' and
403403
'%(PackageReference.Identity)' != 'NETStandard.Library' and
404-
'%(PackageReference.PrivateAssets)' != 'all' and
405-
'%(PackageReference.Pack)' != 'false'">
404+
'%(PackageReference.Pack)' != 'false' and
405+
('%(PackageReference.PrivateAssets)' != 'all' or '%(PackageReference.Pack)' == 'true')">
406406
<PackFolder>Dependency</PackFolder>
407407
<!--<FrameworkSpecific Condition="'$(BuildOutputFrameworkSpecific)' == 'true'">true</FrameworkSpecific>-->
408408
</_InferredPackageFile>

src/NuGetizer.Tests/InlineProjectTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,5 +1053,32 @@ public void when_packagepath_ends_in_path_then_packs_basedir_dir()
10531053
PackagePath = "assets/screen.png",
10541054
}));
10551055
}
1056+
1057+
[Fact]
1058+
public void when_dependency_is_development_dependency_then_can_explicitly_pack_it()
1059+
{
1060+
var result = Builder.BuildProject(
1061+
"""
1062+
<Project Sdk="Microsoft.NET.Sdk">
1063+
<PropertyGroup>
1064+
<TargetFramework>netstandard2.0</TargetFramework>
1065+
<IsPackable>true</IsPackable>
1066+
</PropertyGroup>
1067+
<ItemGroup>
1068+
<PackageReference Include="ThisAssembly.Constants" Version="1.2.14" Pack="true" TargetFramework="netstandard2.0" />
1069+
</ItemGroup>
1070+
</Project>
1071+
"""
1072+
, "GetPackageContents", output);
1073+
1074+
result.AssertSuccess(output);
1075+
1076+
Assert.Contains(result.Items, item => item.Matches(new
1077+
{
1078+
Identity = "ThisAssembly.Constants",
1079+
PackFolder = "Dependency",
1080+
}));
1081+
}
1082+
10561083
}
10571084
}

0 commit comments

Comments
 (0)