Skip to content

Commit

Permalink
Fix: DLLs missing from NuGet packages (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmus authored Feb 23, 2022
1 parent 5d711a6 commit 897e74b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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`,
Expand Down
12 changes: 12 additions & 0 deletions Source/Bake.Tests/Helpers/NuGetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,7 +40,13 @@ public static async Task<NuSpec> 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));
Expand All @@ -47,22 +55,26 @@ public static async Task<NuSpec> LoadAsync(

return new NuSpec(
nuSpecReader.GetId(),
files,
repositoryMetadata?.Url,
repositoryMetadata?.Commit);
}

public class NuSpec
{
public string Id { get; }
public IReadOnlyCollection<string> Files { get; }
public string RepositoryCommit { get; }
public string RepositoryUrl { get; }

public NuSpec(
string id,
IReadOnlyCollection<string> files,
string? repositoryUrl,
string? repositoryCommit)
{
Id = id;
Files = files;
RepositoryCommit = repositoryCommit ?? string.Empty;
RepositoryUrl = repositoryUrl ?? string.Empty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public async Task Run()
// Act
var returnCode = await ExecuteAsync(
"run",
"--log-level:Verbose",
"--build-version", version);

// Assert
Expand All @@ -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");
}
}
}
7 changes: 3 additions & 4 deletions Source/Bake/Cooking/Composers/DotNetComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public class DotNetComposer : Composer
["IncludeSymbols"] = "true",
["DebugType"] = "portable",
["SymbolPackageFormat"] = "snupkg",
["AllowedOutputExtensionsInPackageBuildOutputFolder"] = "$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb",
};
};

public override IReadOnlyCollection<ArtifactType> Produces { get; } = new[]
{
Expand Down Expand Up @@ -313,11 +312,12 @@ private static Recipe CreateBuildRecipe(
properties);
}

private Dictionary<string, string> CreateProperties(
private static Dictionary<string, string> 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;
Expand All @@ -330,7 +330,6 @@ private Dictionary<string, string> CreateProperties(
properties["RepositoryCommit"] = git.Sha;
properties["RepositoryUrl"] = git.OriginUrl.AbsoluteUri;
}

if (ingredients.GitHub != null)
{
var gitHub = ingredients.GitHub;
Expand Down
4 changes: 1 addition & 3 deletions Source/Bake/Services/Tools/DotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public async Task<IToolResult> 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)
Expand Down Expand Up @@ -200,9 +200,7 @@ public async Task<IToolResult> 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,
Expand Down

0 comments on commit 897e74b

Please sign in to comment.