Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing part of the previous fix to pack private assets #390

Merged
merged 1 commit into from
May 5, 2023
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
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);
}
}
}
}