Skip to content
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
9 changes: 9 additions & 0 deletions docs/guide/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ One section per SDK version, newest first. The SDK is in Alpha: a version may ch
every such change is in the [migration notes](../migrations.md). Releases are tagged `sdk-v<version>`; the demo
releases (`v0.1.0`, `v0.2.0`...) are separate.

## Next release

**Fixed**

- `microengine package windows`, `linux` and `macos` stopped with `NETSDK1004` ("assets file not found") for a game
whose `Directory.Build.props` moves the restore output when the package's publish properties are set: the tool
looked for the .NET runtime pack the build used without those properties. It now reads it with the same properties
as the publish.

## 0.6.0-alpha.1

An eighth package: `MicroEngine.Physics.Box2D`, optional, for dynamic bodies. Diagnostics for finding out why a game
Expand Down
16 changes: 12 additions & 4 deletions src/MicroEngine.Cli/Packaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ private string Required(string name)
/// application bundle.</summary>
public static class Packaging
{
/// <summary>The MSBuild properties of a desktop package's publish, given to every MSBuild call about that publish.</summary>
public static readonly string[] DesktopPublishProperties =
[
"-p:PublishSingleFile=true", "-p:EnableCompressionInSingleFile=true", "-p:MicroEngineNativePackage=true", "-p:DebugType=none",
"-p:DebugSymbols=false", "-p:InvariantGlobalization=true", "-p:PublishDocumentationFiles=false", "-p:PublishReferencesDocumentationFiles=false",
];

public static async Task<string> Desktop(PackageRequest request)
{
var (game, t) = (request.Game, request.Target);
Expand All @@ -79,9 +86,8 @@ public static async Task<string> Desktop(PackageRequest request)
{
string publish = Path.Combine(stage, "publish");
Console.WriteLine($"Publishing {game.Title} for {t.Label}...");
Tool.Run(Tool.Dotnet, ["publish", game.Path, "-c", "Release", "-r", t.Rid, "--self-contained", "-p:PublishSingleFile=true",
"-p:EnableCompressionInSingleFile=true", "-p:MicroEngineNativePackage=true", "-p:DebugType=none", "-p:DebugSymbols=false",
"-p:InvariantGlobalization=true", "-p:PublishDocumentationFiles=false", "-p:PublishReferencesDocumentationFiles=false", "-o", publish, "-nologo"], game.Directory, "dotnet publish");
Tool.Run(Tool.Dotnet, ["publish", game.Path, "-c", "Release", "-r", t.Rid, "--self-contained", .. DesktopPublishProperties, "-o", publish, "-nologo"],
game.Directory, "dotnet publish");
string top = Path.Combine(stage, game.Id);
Directory.CreateDirectory(top);
string exe = t.Name == "windows" ? $"{game.Id}.exe" : game.Id;
Expand Down Expand Up @@ -111,7 +117,9 @@ public static async Task<string> Desktop(PackageRequest request)
File.WriteAllText(Path.Combine(top, $"{desktopId}.desktop"), DesktopEntry(game, icon is not null));
}
}
var runtime = RuntimePack(game.Path, t.Rid);
// The same properties as the publish: one of them may move the project's restore output (a game's own
// Directory.Build.props can put it under another obj folder), and the query reads that output.
var runtime = RuntimePack(game.Path, t.Rid, DesktopPublishProperties);
var info = BuildInfo(request, signing, runtime.Version);
WriteCommon(top, game, t, runtime, info);
Directory.CreateDirectory(request.Out);
Expand Down
37 changes: 37 additions & 0 deletions tests/MicroEngine.Cli.Tests/NoticesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,43 @@ public void The_runtime_licences_come_from_the_runtime_pack_MSBuild_resolved_not
Assert.ThrowsExactly<CliException>(() => Packaging.ParseRuntimePack("warning: not JSON"));
}

[TestMethod]
public void The_runtime_pack_is_resolved_with_the_publish_properties_that_move_the_restore_output()
{
// As in the repository's demos: a publish property moves the restore output to obj/package/. Resolving the runtime
// pack without that property reads obj/, which a fresh checkout does not have.
string dir = Directory.CreateTempSubdirectory("microengine-runtime-pack-").FullName;
try
{
File.WriteAllText(Path.Combine(dir, "Directory.Build.props"), """
<Project>
<PropertyGroup Condition="'$(MicroEngineNativePackage)' == 'true'">
<BaseIntermediateOutputPath>obj/package/</BaseIntermediateOutputPath>
</PropertyGroup>
</Project>
""");
string project = Path.Combine(dir, "Game.csproj");
File.WriteAllText(project, """
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net10.0</TargetFramework></PropertyGroup>
</Project>
""");
string rid = System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier;
Tool.Run(Tool.Dotnet, ["restore", project, "-r", rid, "-p:SelfContained=true", .. Packaging.DesktopPublishProperties, "-nologo"], dir, "restore");
Assert.IsFalse(File.Exists(Path.Combine(dir, "obj", "project.assets.json")), "the restore output is under obj/package/ only");
Assert.IsTrue(File.Exists(Path.Combine(dir, "obj", "package", "project.assets.json")));

var runtime = Packaging.RuntimePack(project, rid, Packaging.DesktopPublishProperties);
StringAssert.StartsWith(runtime.Version, "10.0.");
Assert.IsTrue(Directory.Exists(runtime.Directory), runtime.Directory);
Assert.ThrowsExactly<CliException>(() => Packaging.RuntimePack(project, rid), "without the properties MSBuild reads obj/, which has no restore output");
}
finally
{
Directory.Delete(dir, recursive: true);
}
}

[TestMethod]
public void A_runtime_pack_without_its_licence_files_is_an_error_that_names_the_folder()
{
Expand Down
Loading