Add CLI entry point and update packaging metadata

Introduces a new Cli.cs file providing a command-line interface for packing and unpacking with AzuresPackager. Updates project metadata in AzuresPackager.csproj, including package version, output type, and dependency version bump for SharpCompress. Also updates publish.ps1 to use the new version and skip duplicate package uploads.
This commit is contained in:
Gilles Lazures 2026-01-27 02:02:49 +01:00
parent aa569bcfaf
commit 3dc178c683
4 changed files with 66 additions and 12 deletions

View File

@ -1,16 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>./nupkg</PackageOutputPath>
<Authors>azures04</Authors>
<RepositoryUrl>https://gitea.azures.fr/azures04/AzuresPackager</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageId>AzuresPackager</PackageId>
<Version>0.0.2</Version>
<Authors>Azures04</Authors>
<PackAsTool>false</PackAsTool>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SharpCompress" Version="0.30.0" />
<PackageReference Include="SharpCompress" Version="0.34.1" />
</ItemGroup>
</Project>

55
Cli.cs Normal file
View File

@ -0,0 +1,55 @@
namespace AzuresPackager.Cli;
public class Program {
public static void Main(string[] args) {
var arguments = new Dictionary<string, string>();
for (int i = 0; i < args.Length; i++) {
if (args[i].StartsWith("--") && i + 1 < args.Length) {
arguments[args[i].ToLower()] = args[i + 1];
i++;
}
}
if (arguments.ContainsKey("--action") || !arguments.ContainsKey("--sourcedir") || !arguments.ContainsKey("--outputpath") || !arguments.ContainsKey("--key")) {
Console.WriteLine("Usage: AzuresPackager.Cli --action <[pack/unpack]> --sourceDir <path> --outputPath <path> --key <byte>");
return;
}
string source = arguments["--sourcedir"];
string output = arguments["--outputpath"];
if (!byte.TryParse(arguments["--key"], out byte key)) {
Console.WriteLine("Erreur : La clé XOR (--key) doit être un nombre entre 0 et 255.");
return;
}
switch (arguments["--action"]) {
case "pack":
try {
Console.WriteLine($"[AzuresPackager] Packaging : {source} -> {output} (Key: {key})");
Packager.Pack(source, output, key);
Console.WriteLine("[AzuresPackager] Success");
Environment.Exit(0);
} catch (Exception ex) {
Console.WriteLine($"[AzuresPackager] Erreur : {ex.Message}");
Environment.Exit(1);
}
break;
case "unpack":
try {
Console.WriteLine($"[AzuresPackager] Unpackaging : {source} -> {output} (Key: {key})");
AzuresPackage azp = new AzuresPackage(source, key);
azp.Unpack(output);
Console.WriteLine("[AzuresPackager] Success");
Environment.Exit(0);
} catch (Exception ex) {
Console.WriteLine($"[AzuresPackager] Erreur : {ex.Message}");
Environment.Exit(1);
}
break;
default:
break;
}
}
}

View File

@ -1,11 +1,7 @@
using System.IO;
using System.Text;
using System.Text;
using SharpCompress.Archives;
using SharpCompress.Common;
using SharpCompress.Writers;
using System.Collections.Generic;
using System.Linq;
using System;
namespace AzuresPackager;

View File

@ -1,5 +1,5 @@
clear
$version = "0.0.1"
$version = "0.0.2"
Write-Host "`r`n[Task 1/4] Cleaning project..." -ForegroundColor Magenta
dotnet clean
@ -14,4 +14,4 @@ Write-Host "`r`n[Task 4/4] Packing project..." -ForegroundColor Magenta
dotnet pack --version $version
Write-Host "`r`n[Task 5/4] Publishing project..." -ForegroundColor Magenta
dotnet nuget push --source AzuresGitea "nupkg\AzuresPackager.$version.nupkg"
dotnet nuget push --source AzuresGitea "nupkg\AzuresPackager.$version.nupkg" --skip-duplicate