Skip to content

Commit a3321f4

Browse files
committed
Replace --rid with --arch in pending packagers
1 parent 2fb836d commit a3321f4

File tree

9 files changed

+87
-679
lines changed

9 files changed

+87
-679
lines changed

AGENTS.md

Lines changed: 37 additions & 258 deletions
Large diffs are not rendered by default.

WARP.md

Lines changed: 8 additions & 388 deletions
Large diffs are not rendered by default.

src/DotnetPackaging.Tool/Commands/AppImageCommand.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.CommandLine;
2-
using System.Runtime.InteropServices;
32
using CSharpFunctionalExtensions;
43
using DotnetPackaging.AppImage;
54
using DotnetPackaging.AppImage.Core;
@@ -213,7 +212,7 @@ private static Task CreateAppImageFromAppDir(DirectoryInfo appDir, FileInfo outp
213212
private static void AddFromProjectSubcommand(Command appImageCommand)
214213
{
215214
var project = new Option<FileInfo>("--project") { Description = "Path to the .csproj file", Required = true };
216-
var rid = new Option<string?>("--rid") { Description = "Runtime identifier (e.g. linux-x64, linux-arm64)" };
215+
var arch = new Option<string?>("--arch") { Description = "Target architecture (x64, arm64)" };
217216
var selfContained = new Option<bool>("--self-contained") { Description = "Publish self-contained" };
218217
selfContained.DefaultValueFactory = _ => true;
219218
var configuration = new Option<string>("--configuration") { Description = "Build configuration" };
@@ -243,7 +242,7 @@ private static void AddFromProjectSubcommand(Command appImageCommand)
243242

244243
var fromProject = new Command("from-project") { Description = "Publish a .NET project and build an AppImage from the published output." };
245244
fromProject.Add(project);
246-
fromProject.Add(rid);
245+
fromProject.Add(arch);
247246
fromProject.Add(selfContained);
248247
fromProject.Add(configuration);
249248
fromProject.Add(singleFile);
@@ -274,21 +273,22 @@ private static void AddFromProjectSubcommand(Command appImageCommand)
274273
var tr = parseResult.GetValue(trimmed);
275274
var outFile = parseResult.GetValue(output)!;
276275
var opt = optionsBinder.Bind(parseResult);
277-
var ridVal = parseResult.GetValue(rid);
276+
var archVal = parseResult.GetValue(arch);
278277

279278
await ExecutionWrapper.ExecuteWithLogging("appimage-from-project", outFile.FullName, async logger =>
280279
{
281-
if (string.IsNullOrWhiteSpace(ridVal) && !RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
280+
var ridResult = RidUtils.ResolveLinuxRid(archVal, "AppImage packaging");
281+
if (ridResult.IsFailure)
282282
{
283-
logger.Error("--rid is required when building AppImage from-project on non-Linux hosts (e.g., linux-x64/linux-arm64).");
283+
logger.Error("Invalid architecture: {Error}", ridResult.Error);
284284
Environment.ExitCode = 1;
285285
return;
286286
}
287287

288288
var publisher = new DotnetPackaging.Publish.DotnetPublisher(Maybe<ILogger>.From(logger));
289289
var req = new DotnetPackaging.Publish.ProjectPublishRequest(prj.FullName)
290290
{
291-
Rid = string.IsNullOrWhiteSpace(ridVal) ? Maybe<string>.None : Maybe<string>.From(ridVal!),
291+
Rid = string.IsNullOrWhiteSpace(archVal) ? Maybe<string>.None : Maybe<string>.From(ridResult.Value),
292292
SelfContained = sc,
293293
Configuration = cfg,
294294
SingleFile = sf,

src/DotnetPackaging.Tool/Commands/DebCommand.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.CommandLine;
2-
using System.Runtime.InteropServices;
32
using CSharpFunctionalExtensions;
43
using DotnetPackaging.Deb.Archives.Deb;
54
using Serilog;
@@ -48,7 +47,7 @@ private static Task CreateDeb(DirectoryInfo inputDir, FileInfo outputFile, Optio
4847
private static void AddFromProjectSubcommand(Command debCommand)
4948
{
5049
var project = new Option<FileInfo>("--project") { Description = "Path to the .csproj file", Required = true };
51-
var rid = new Option<string?>("--rid") { Description = "Runtime identifier (e.g. linux-x64, linux-arm64)" };
50+
var arch = new Option<string?>("--arch") { Description = "Target architecture (x64, arm64)" };
5251
var selfContained = new Option<bool>("--self-contained") { Description = "Publish self-contained" };
5352
selfContained.DefaultValueFactory = _ => true;
5453
var configuration = new Option<string>("--configuration") { Description = "Build configuration" };
@@ -78,7 +77,7 @@ private static void AddFromProjectSubcommand(Command debCommand)
7877

7978
var fromProject = new Command("from-project") { Description = "Publish a .NET project and build a Debian .deb from the published output." };
8079
fromProject.Add(project);
81-
fromProject.Add(rid);
80+
fromProject.Add(arch);
8281
fromProject.Add(selfContained);
8382
fromProject.Add(configuration);
8483
fromProject.Add(singleFile);
@@ -109,21 +108,22 @@ private static void AddFromProjectSubcommand(Command debCommand)
109108
var tr = parseResult.GetValue(trimmed);
110109
var outFile = parseResult.GetValue(output)!;
111110
var opt = optionsBinder.Bind(parseResult);
112-
var ridVal = parseResult.GetValue(rid);
111+
var archVal = parseResult.GetValue(arch);
113112

114113
await ExecutionWrapper.ExecuteWithLogging("deb-from-project", outFile.FullName, async logger =>
115114
{
116-
if (string.IsNullOrWhiteSpace(ridVal) && !RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
115+
var ridResult = RidUtils.ResolveLinuxRid(archVal, "DEB packaging");
116+
if (ridResult.IsFailure)
117117
{
118-
logger.Error("--rid is required when building DEB from-project on non-Linux hosts (e.g., linux-x64/linux-arm64).");
118+
logger.Error("Invalid architecture: {Error}", ridResult.Error);
119119
Environment.ExitCode = 1;
120120
return;
121121
}
122122

123123
var publisher = new DotnetPackaging.Publish.DotnetPublisher();
124124
var req = new DotnetPackaging.Publish.ProjectPublishRequest(prj.FullName)
125125
{
126-
Rid = string.IsNullOrWhiteSpace(ridVal) ? Maybe<string>.None : Maybe<string>.From(ridVal!),
126+
Rid = string.IsNullOrWhiteSpace(archVal) ? Maybe<string>.None : Maybe<string>.From(ridResult.Value),
127127
SelfContained = sc,
128128
Configuration = cfg,
129129
SingleFile = sf,

src/DotnetPackaging.Tool/Commands/DmgCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ await ExecutionWrapper.ExecuteWithLogging("dmg-from-project", outFile.FullName,
120120
var ridResult = RidUtils.ResolveMacRid(ridVal);
121121
if (ridResult.IsFailure)
122122
{
123-
logger.Error("Invalid RID: {Error}", ridResult.Error);
123+
logger.Error("Invalid architecture: {Error}", ridResult.Error);
124124
Environment.ExitCode = 1;
125125
return;
126126
}

src/DotnetPackaging.Tool/Commands/ExeCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ await ExecutionWrapper.ExecuteWithLogging("exe", outFile.FullName, async logger
129129
var ridResult = RidUtils.ResolveWindowsRid(archOpt, "EXE packaging");
130130
if (ridResult.IsFailure)
131131
{
132-
logger.Error("Invalid RID: {Error}", ridResult.Error);
132+
logger.Error("Invalid architecture: {Error}", ridResult.Error);
133133
Environment.ExitCode = 1;
134134
return;
135135
}
@@ -231,7 +231,7 @@ await ExecutionWrapper.ExecuteWithLogging("exe-from-project", extrasOutput.FullN
231231
var ridResult = RidUtils.ResolveWindowsRid(archVal, "EXE packaging");
232232
if (ridResult.IsFailure)
233233
{
234-
logger.Error("Invalid RID: {Error}", ridResult.Error);
234+
logger.Error("Invalid architecture: {Error}", ridResult.Error);
235235
Environment.ExitCode = 1;
236236
return;
237237
}

src/DotnetPackaging.Tool/Commands/MsixCommand.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.CommandLine;
2-
using System.Runtime.InteropServices;
32
using CSharpFunctionalExtensions;
43
using DotnetPackaging.Msix;
54
using Serilog;
@@ -50,7 +49,7 @@ await ExecutionWrapper.ExecuteWithLogging("msix-pack", outFile.FullName, async l
5049
msixCommand.Add(packCmd);
5150

5251
var project = new Option<FileInfo>("--project") { Description = "Path to the .csproj file", Required = true };
53-
var rid = new Option<string?>("--rid") { Description = "Runtime identifier (e.g. win-x64)" };
52+
var arch = new Option<string?>("--arch") { Description = "Target architecture (x64, arm64)" };
5453
var selfContained = new Option<bool>("--self-contained") { Description = "Publish self-contained" };
5554
selfContained.DefaultValueFactory = _ => false;
5655
var configuration = new Option<string>("--configuration") { Description = "Build configuration" };
@@ -60,7 +59,7 @@ await ExecutionWrapper.ExecuteWithLogging("msix-pack", outFile.FullName, async l
6059
var outMsix = new Option<FileInfo>("--output") { Description = "Output .msix file", Required = true };
6160
var fromProject = new Command("from-project") { Description = "Publish a .NET project and build an MSIX from the published output (expects manifest/assets)." };
6261
fromProject.Add(project);
63-
fromProject.Add(rid);
62+
fromProject.Add(arch);
6463
fromProject.Add(selfContained);
6564
fromProject.Add(configuration);
6665
fromProject.Add(singleFile);
@@ -74,21 +73,22 @@ await ExecutionWrapper.ExecuteWithLogging("msix-pack", outFile.FullName, async l
7473
var sf = parseResult.GetValue(singleFile);
7574
var tr = parseResult.GetValue(trimmed);
7675
var outFile = parseResult.GetValue(outMsix)!;
77-
var ridVal = parseResult.GetValue(rid);
76+
var archVal = parseResult.GetValue(arch);
7877

7978
await ExecutionWrapper.ExecuteWithLogging("msix-from-project", outFile.FullName, async logger =>
8079
{
81-
if (string.IsNullOrWhiteSpace(ridVal) && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
80+
var ridResult = RidUtils.ResolveWindowsRid(archVal, "MSIX packaging");
81+
if (ridResult.IsFailure)
8282
{
83-
logger.Error("--rid is required when building MSIX from-project on non-Windows hosts (e.g., win-x64/win-arm64).");
83+
logger.Error("Invalid architecture: {Error}", ridResult.Error);
8484
Environment.ExitCode = 1;
8585
return;
8686
}
8787

8888
var publisher = new DotnetPackaging.Publish.DotnetPublisher();
8989
var req = new DotnetPackaging.Publish.ProjectPublishRequest(prj.FullName)
9090
{
91-
Rid = string.IsNullOrWhiteSpace(ridVal) ? Maybe<string>.None : Maybe<string>.From(ridVal!),
91+
Rid = string.IsNullOrWhiteSpace(archVal) ? Maybe<string>.None : Maybe<string>.From(ridResult.Value),
9292
SelfContained = sc,
9393
Configuration = cfg,
9494
SingleFile = sf,

src/DotnetPackaging.Tool/Commands/RidUtils.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Linq;
12
using System.Runtime.InteropServices;
23
using CSharpFunctionalExtensions;
34
using RuntimeArchitecture = System.Runtime.InteropServices.Architecture;
@@ -11,6 +12,11 @@ public static Result<string> ResolveWindowsRid(string? architecture, string cont
1112
return ResolveRidForPlatform(architecture, OSPlatform.Windows, "Windows", "win", context);
1213
}
1314

15+
public static Result<string> ResolveLinuxRid(string? architecture, string context)
16+
{
17+
return ResolveRidForPlatform(architecture, OSPlatform.Linux, "Linux", "linux", context);
18+
}
19+
1420
public static Result<string> ResolveMacRid(string? architecture)
1521
{
1622
return ResolveRidForPlatform(architecture, OSPlatform.OSX, "macOS", "osx", "DMG packaging");
@@ -65,9 +71,12 @@ private static Result<string> MapArchitectureToRid(RuntimeArchitecture architect
6571

6672
private static RuntimeArchitecture? ParseRuntimeArchitecture(string architecture)
6773
{
68-
return architecture.ToLowerInvariant() switch
74+
var normalized = architecture.ToLowerInvariant();
75+
var archPart = normalized.Split('-').Last();
76+
77+
return archPart switch
6978
{
70-
"x64" => RuntimeArchitecture.X64,
79+
"x64" or "amd64" => RuntimeArchitecture.X64,
7180
"arm64" => RuntimeArchitecture.Arm64,
7281
_ => null
7382
};

src/DotnetPackaging.Tool/Commands/RpmCommand.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.CommandLine;
2-
using System.Runtime.InteropServices;
32
using CSharpFunctionalExtensions;
43
using DotnetPackaging.Rpm;
54
using Serilog;
@@ -61,7 +60,7 @@ private static Result CopyRpmToOutput(FileInfo rpmFile, FileInfo outputFile)
6160
private static void AddFromProjectSubcommand(Command rpmCommand)
6261
{
6362
var project = new Option<FileInfo>("--project") { Description = "Path to the .csproj file", Required = true };
64-
var rid = new Option<string?>("--rid") { Description = "Runtime identifier (e.g. linux-x64, linux-arm64)" };
63+
var arch = new Option<string?>("--arch") { Description = "Target architecture (x64, arm64)" };
6564
var selfContained = new Option<bool>("--self-contained") { Description = "Publish self-contained" };
6665
selfContained.DefaultValueFactory = _ => true;
6766
var configuration = new Option<string>("--configuration") { Description = "Build configuration" };
@@ -91,7 +90,7 @@ private static void AddFromProjectSubcommand(Command rpmCommand)
9190

9291
var fromProject = new Command("from-project") { Description = "Publish a .NET project and build an RPM from the published output (no code duplication; library drives the pipeline)." };
9392
fromProject.Add(project);
94-
fromProject.Add(rid);
93+
fromProject.Add(arch);
9594
fromProject.Add(selfContained);
9695
fromProject.Add(configuration);
9796
fromProject.Add(singleFile);
@@ -122,21 +121,22 @@ private static void AddFromProjectSubcommand(Command rpmCommand)
122121
var tr = parseResult.GetValue(trimmed);
123122
var outFile = parseResult.GetValue(output)!;
124123
var opt = optionsBinder.Bind(parseResult);
125-
var ridVal = parseResult.GetValue(rid);
124+
var archVal = parseResult.GetValue(arch);
126125

127126
await ExecutionWrapper.ExecuteWithLogging("rpm-from-project", outFile.FullName, async logger =>
128127
{
129-
if (string.IsNullOrWhiteSpace(ridVal) && !RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
128+
var ridResult = RidUtils.ResolveLinuxRid(archVal, "RPM packaging");
129+
if (ridResult.IsFailure)
130130
{
131-
logger.Error("--rid is required when building RPM from-project on non-Linux hosts (e.g., linux-x64/linux-arm64).");
131+
logger.Error("Invalid architecture: {Error}", ridResult.Error);
132132
Environment.ExitCode = 1;
133133
return;
134134
}
135135

136136
var publisher = new DotnetPackaging.Publish.DotnetPublisher();
137137
var req = new DotnetPackaging.Publish.ProjectPublishRequest(prj.FullName)
138138
{
139-
Rid = string.IsNullOrWhiteSpace(ridVal) ? Maybe<string>.None : Maybe<string>.From(ridVal!),
139+
Rid = string.IsNullOrWhiteSpace(archVal) ? Maybe<string>.None : Maybe<string>.From(ridResult.Value),
140140
SelfContained = sc,
141141
Configuration = cfg,
142142
SingleFile = sf,

0 commit comments

Comments
 (0)