mirror of
https://github.com/quamotion/dotnet-packaging.git
synced 2026-07-09 02:16:10 +00:00
Add the dotnet-rpm command line utility
This commit is contained in:
83
dotnet-rpm/Program.cs
Normal file
83
dotnet-rpm/Program.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using Microsoft.Extensions.CommandLineUtils;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
CommandLineApplication commandLineApplication = new CommandLineApplication(throwOnUnexpectedArg: true);
|
||||
|
||||
CommandOption runtime = commandLineApplication.Option(
|
||||
"-r |--runtime <runtime>",
|
||||
"Target runtime of the RPM package. The target runtime has to be specified in the project file.",
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption framework = commandLineApplication.Option(
|
||||
"-f | --framework <framework>",
|
||||
"Required. Target framework of the RPM package. The target framework has to be specified in the project file.",
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption configuration = commandLineApplication.Option(
|
||||
"-c | --configuration <configuration>",
|
||||
"Required. Target configuration of the RPM package. The default for most projects is 'Debug'.",
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
CommandOption versionSuffix = commandLineApplication.Option(
|
||||
"---version-suffix <version-suffix>",
|
||||
"Defines the value for the $(VersionSuffix) property in the project.",
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
commandLineApplication.HelpOption("-? | -h | --help");
|
||||
|
||||
commandLineApplication.OnExecute(() =>
|
||||
{
|
||||
if (!framework.HasValue())
|
||||
{
|
||||
Console.WriteLine("You must specify a target framework.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!runtime.HasValue())
|
||||
{
|
||||
Console.WriteLine("You must specify a target runtime.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
StringBuilder msbuildArguments = new StringBuilder();
|
||||
msbuildArguments.Append("msbuild /t:CreateRpm ");
|
||||
msbuildArguments.Append($"/p:RuntimeIdentifier={runtime.Value()} ");
|
||||
msbuildArguments.Append($"/p:TargetFramework={framework.Value()} ");
|
||||
|
||||
if (configuration.HasValue())
|
||||
{
|
||||
msbuildArguments.Append($"/p:Configuration={configuration.Value()} ");
|
||||
}
|
||||
|
||||
if (versionSuffix.HasValue())
|
||||
{
|
||||
msbuildArguments.Append($"/p:VersionSuffix={versionSuffix.Value()} ");
|
||||
}
|
||||
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = "dotnet",
|
||||
Arguments = msbuildArguments.ToString()
|
||||
};
|
||||
|
||||
var process = new Process
|
||||
{
|
||||
StartInfo = psi,
|
||||
|
||||
};
|
||||
|
||||
process.Start();
|
||||
process.WaitForExit();
|
||||
|
||||
return process.ExitCode;
|
||||
});
|
||||
|
||||
return commandLineApplication.Execute(args);
|
||||
}
|
||||
}
|
||||
36
dotnet-rpm/dotnet-rpm.csproj
Normal file
36
dotnet-rpm/dotnet-rpm.csproj
Normal file
@@ -0,0 +1,36 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||
<VersionPrefix>0.1.1</VersionPrefix>
|
||||
<Authors>Frederik Carlier</Authors>
|
||||
<Company>Quamotion</Company>
|
||||
<Copyright>Copyright (c) Frederik Carlier and Contributors</Copyright>
|
||||
<PackageLicenseUrl>https://github.com/qmfrederik/dotnet-packaging/blob/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://github.com/qmfrederik/dotnet-packaging/</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/qmfrederik/dotnet-packaging/</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageTags>dotnet cli packaging rpm package installer</PackageTags>
|
||||
<Description>
|
||||
Create RPM packages (.rpm files) of your .NET Core projects straight from the command line.
|
||||
|
||||
Once you've installed this package as a .NET CLI tool, run dotnet rpm to generate a .rpm package which contains the publish output of your .NET Project.
|
||||
|
||||
See https://github.com/qmfrederik/dotnet-packaging/ for more information on how to use dotnet rpm.
|
||||
</Description>
|
||||
<Product>Packaging Tools for .NET CLI</Product>
|
||||
<NugetPackageFolder Condition="$(NugetPackageFolder) == ''">$(USERPROFILE)\.nuget\packages</NugetPackageFolder>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="$(NugetPackageFolder)\microsoft.extensions.commandlineutils\1.1.1\lib\netstandard1.3\Microsoft.Extensions.CommandLineUtils.dll" Link="Microsoft.Extensions.CommandLineUtils.dll">
|
||||
<Pack>true</Pack>
|
||||
<PackagePath>lib\$(TargetFramework)\</PackagePath>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user