From 897e74b4ca9e50a1848df1a3adac54cf6af33584 Mon Sep 17 00:00:00 2001 From: Rasmus Mikkelsen Date: Wed, 23 Feb 2022 16:59:20 +0100 Subject: [PATCH] Fix: DLLs missing from NuGet packages (#73) --- .github/workflows/pull-requests.yml | 2 +- .github/workflows/release.yml | 2 +- RELEASE_NOTES.md | 4 ++++ Source/Bake.Tests/Helpers/NuGetHelper.cs | 12 ++++++++++++ .../BakeTests/NetCorePackageTests.cs | 2 ++ Source/Bake/Cooking/Composers/DotNetComposer.cs | 7 +++---- Source/Bake/Services/Tools/DotNet.cs | 4 +--- 7 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 918d1515..368b8557 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -57,4 +57,4 @@ jobs: run: dotnet publish -o bake-it Source/Bake - name: Run Bake - run: bake-it/bake run --build-version 0.9.$GITHUB_RUN_NUMBER + run: bake-it/bake run --build-version 0.10.$GITHUB_RUN_NUMBER diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 231f05cc..b153057a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,4 +57,4 @@ jobs: run: dotnet publish -o bake-it Source/Bake - name: Run Bake - run: bake-it/bake run --convention=Release --build-version 0.9.$GITHUB_RUN_NUMBER --destination="nuget>github,nuget,release>github" + run: bake-it/bake run --convention=Release --build-version 0.10.$GITHUB_RUN_NUMBER --destination="nuget>github,nuget,release>github" diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 845dbd55..14176590 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,7 @@ +# 0.10-beta + +* Fixed: Project DLLs are now actually added to NuGet packages + # 0.9-beta * New: If there is no `.dockerignore` file found when building a `Dockerfile`, diff --git a/Source/Bake.Tests/Helpers/NuGetHelper.cs b/Source/Bake.Tests/Helpers/NuGetHelper.cs index 7d7fd174..e18d6a18 100644 --- a/Source/Bake.Tests/Helpers/NuGetHelper.cs +++ b/Source/Bake.Tests/Helpers/NuGetHelper.cs @@ -21,7 +21,9 @@ // SOFTWARE. using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading.Tasks; using System.Xml.Linq; using NuGet.Packaging; @@ -38,7 +40,13 @@ public static async Task LoadAsync( await using var fileStream = File.Open(packagePath, FileMode.Open); using var packageArchiveReader = new PackageArchiveReader(fileStream); var nuSpecReader = packageArchiveReader.NuspecReader; + var files = packageArchiveReader.GetFiles().ToArray(); + Console.WriteLine(new string('=', 42)); + foreach (var file in files) + { + Console.WriteLine(file); + } Console.WriteLine(new string('=', 42)); Console.WriteLine(nuSpecReader.Xml.ToString(SaveOptions.None)); Console.WriteLine(new string('=', 42)); @@ -47,6 +55,7 @@ public static async Task LoadAsync( return new NuSpec( nuSpecReader.GetId(), + files, repositoryMetadata?.Url, repositoryMetadata?.Commit); } @@ -54,15 +63,18 @@ public static async Task LoadAsync( public class NuSpec { public string Id { get; } + public IReadOnlyCollection Files { get; } public string RepositoryCommit { get; } public string RepositoryUrl { get; } public NuSpec( string id, + IReadOnlyCollection files, string? repositoryUrl, string? repositoryCommit) { Id = id; + Files = files; RepositoryCommit = repositoryCommit ?? string.Empty; RepositoryUrl = repositoryUrl ?? string.Empty; } diff --git a/Source/Bake.Tests/IntegrationTests/BakeTests/NetCorePackageTests.cs b/Source/Bake.Tests/IntegrationTests/BakeTests/NetCorePackageTests.cs index 402413dd..a52ca712 100644 --- a/Source/Bake.Tests/IntegrationTests/BakeTests/NetCorePackageTests.cs +++ b/Source/Bake.Tests/IntegrationTests/BakeTests/NetCorePackageTests.cs @@ -46,6 +46,7 @@ public async Task Run() // Act var returnCode = await ExecuteAsync( "run", + "--log-level:Verbose", "--build-version", version); // Assert @@ -56,6 +57,7 @@ public async Task Run() $"{ProjectName}.{version}.nupkg"); nuSpec.RepositoryUrl.Should().Be(RepositoryUrl); nuSpec.RepositoryCommit.Should().Be(Sha); + nuSpec.Files.Should().Contain("lib/net6.0/NetCore.Package.dll"); } } } diff --git a/Source/Bake/Cooking/Composers/DotNetComposer.cs b/Source/Bake/Cooking/Composers/DotNetComposer.cs index fe3fb824..455cedd8 100644 --- a/Source/Bake/Cooking/Composers/DotNetComposer.cs +++ b/Source/Bake/Cooking/Composers/DotNetComposer.cs @@ -54,8 +54,7 @@ public class DotNetComposer : Composer ["IncludeSymbols"] = "true", ["DebugType"] = "portable", ["SymbolPackageFormat"] = "snupkg", - ["AllowedOutputExtensionsInPackageBuildOutputFolder"] = "$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb", - }; + }; public override IReadOnlyCollection Produces { get; } = new[] { @@ -313,11 +312,12 @@ private static Recipe CreateBuildRecipe( properties); } - private Dictionary CreateProperties( + private static Dictionary CreateProperties( ValueObjects.Ingredients ingredients, VisualStudioSolution visualStudioSolution) { var properties = DefaultProperties.ToDictionary(kv => kv.Key, kv => kv.Value); + if (ingredients.ReleaseNotes != null) { properties["PackageReleaseNotes"] = ingredients.ReleaseNotes.Notes; @@ -330,7 +330,6 @@ private Dictionary CreateProperties( properties["RepositoryCommit"] = git.Sha; properties["RepositoryUrl"] = git.OriginUrl.AbsoluteUri; } - if (ingredients.GitHub != null) { var gitHub = ingredients.GitHub; diff --git a/Source/Bake/Services/Tools/DotNet.cs b/Source/Bake/Services/Tools/DotNet.cs index c8cbc5b4..798688a8 100644 --- a/Source/Bake/Services/Tools/DotNet.cs +++ b/Source/Bake/Services/Tools/DotNet.cs @@ -130,7 +130,7 @@ public async Task BuildAsync( "--configuration", argument.Configuration, $"-p:Version={argument.Version}", $"-p:AssemblyVersion={argument.Version.Major}.0.0.0", - $"-p:FileVersion={argument.Version}" + $"-p:FileVersion={argument.Version.LegacyVersion}" }; foreach (var (property, value) in argument.Properties) @@ -200,9 +200,7 @@ public async Task PackAsync( AddIf(!argument.Build, arguments, "--no-build"); AddIf(argument.IncludeSource, arguments, "--include-source"); AddIf(argument.IncludeSymbols, arguments, "--include-symbols"); - AddIf(argument.Build, arguments, "--no-build"); AddIf(!string.IsNullOrEmpty(argument.Version.Meta), arguments, "--version-suffix", argument.Version.Meta); - var buildRunner = _runnerFactory.CreateRunner( "dotnet", argument.WorkingDirectory,