Skip to content

Commit

Permalink
Make sure we can explicitly pack a privateassets/development dependency
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
kzu committed May 5, 2023
1 parent 823924a commit ae7fe3d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/NuGetizer.Tasks/NuGetizer.Inference.targets
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ Copyright (c) .NET Foundation. All rights reserved.
'$(PackAsPublish)' != 'true' and
'%(PackageReference.Identity)' != 'NuGetizer' and
'%(PackageReference.Identity)' != 'NETStandard.Library' and
'%(PackageReference.PrivateAssets)' != 'all' and
'%(PackageReference.Pack)' != 'false'">
'%(PackageReference.Pack)' != 'false' and
('%(PackageReference.PrivateAssets)' != 'all' or '%(PackageReference.Pack)' == 'true')">
<PackFolder>Dependency</PackFolder>
<!--<FrameworkSpecific Condition="'$(BuildOutputFrameworkSpecific)' == 'true'">true</FrameworkSpecific>-->
</_InferredPackageFile>
Expand Down
27 changes: 27 additions & 0 deletions src/NuGetizer.Tests/InlineProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,5 +1053,32 @@ public void when_packagepath_ends_in_path_then_packs_basedir_dir()
PackagePath = "assets/screen.png",
}));
}

[Fact]
public void when_dependency_is_development_dependency_then_can_explicitly_pack_it()
{
var result = Builder.BuildProject(
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>true</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ThisAssembly.Constants" Version="1.2.14" Pack="true" TargetFramework="netstandard2.0" />
</ItemGroup>
</Project>
"""
, "GetPackageContents", output);

result.AssertSuccess(output);

Assert.Contains(result.Items, item => item.Matches(new
{
Identity = "ThisAssembly.Constants",
PackFolder = "Dependency",
}));
}

}
}

0 comments on commit ae7fe3d

Please sign in to comment.