Skip to content

Commit

Permalink
Missing part of the previous fix to pack private assets
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed May 5, 2023
1 parent 88edf4a commit bc3e94a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/NuGetizer.Tasks/CreatePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ void AddDependencies(Manifest manifest)
{
var dependencies = from item in Contents
where PackFolderKind.Dependency.Equals(item.GetMetadata(MetadataName.PackFolder), StringComparison.OrdinalIgnoreCase) &&
!"all".Equals(item.GetMetadata(MetadataName.PrivateAssets), StringComparison.OrdinalIgnoreCase)
(!"all".Equals(item.GetMetadata(MetadataName.PrivateAssets), StringComparison.OrdinalIgnoreCase) ||
"true".Equals(item.GetMetadata("Pack"), StringComparison.OrdinalIgnoreCase))
select new Dependency
{
Id = item.ItemSpec,
Expand Down
24 changes: 20 additions & 4 deletions src/NuGetizer.Tests/InlineProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ public void when_packagepath_ends_in_path_then_packs_basedir_dir()
[Fact]
public void when_dependency_is_development_dependency_then_can_explicitly_pack_it()
{
var result = Builder.BuildProject(
var project =
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
Expand All @@ -1068,8 +1068,8 @@ public void when_dependency_is_development_dependency_then_can_explicitly_pack_i
<PackageReference Include="ThisAssembly.Constants" Version="1.2.14" Pack="true" TargetFramework="netstandard2.0" />
</ItemGroup>
</Project>
"""
, "GetPackageContents", output);
""";
var result = Builder.BuildProject(project, "GetPackageContents", output);

result.AssertSuccess(output);

Expand All @@ -1078,7 +1078,23 @@ public void when_dependency_is_development_dependency_then_can_explicitly_pack_i
Identity = "ThisAssembly.Constants",
PackFolder = "Dependency",
}));
}

result = Builder.BuildProject(project, "Pack", output);

result.AssertSuccess(output);

var package = result.Items[0].ItemSpec;
File.Exists(package);

using (var archive = ZipFile.OpenRead(package))
{
Assert.Contains(archive.Entries, entry => entry.FullName == "scenario.nuspec");
using var stream = archive.Entries.First(x => x.FullName == "scenario.nuspec").Open();
var manifest = Manifest.ReadFrom(stream, false);
Assert.NotEmpty(manifest.Metadata.DependencyGroups);
Assert.NotEmpty(manifest.Metadata.DependencyGroups.First().Packages);
Assert.Equal("ThisAssembly.Constants", manifest.Metadata.DependencyGroups.First().Packages.First().Id);
}
}
}
}

0 comments on commit bc3e94a

Please sign in to comment.