Merge pull request #2035 from eerhardt/Version
Changing --version in the CLI
This commit is contained in:
commit
30346443fb
4 changed files with 41 additions and 7 deletions
|
@ -78,8 +78,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
var configuration = c.BuildContext.Get<string>("Configuration");
|
var configuration = c.BuildContext.Get<string>("Configuration");
|
||||||
|
|
||||||
// Run the build
|
// Run the build
|
||||||
string version = DotNetCli.Stage0.Exec("", "--version").CaptureStdOut().Execute().StdOut;
|
string rid = GetRuntimeId();
|
||||||
string rid = Array.Find<string>(version.Split(Environment.NewLine.ToCharArray()), (e) => e.Contains("Runtime Id:")).Replace("Runtime Id:", "").Trim();
|
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
// Why does Windows directly call cmake but Linux/Mac calls "build.sh" in the corehost dir?
|
// Why does Windows directly call cmake but Linux/Mac calls "build.sh" in the corehost dir?
|
||||||
|
@ -134,6 +133,26 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
return c.Success();
|
return c.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetRuntimeId()
|
||||||
|
{
|
||||||
|
string info = DotNetCli.Stage0.Exec("", "--info").CaptureStdOut().Execute().StdOut;
|
||||||
|
string rid = Array.Find<string>(info.Split(Environment.NewLine.ToCharArray()), (e) => e.Contains("RID:"))?.Replace("RID:", "").Trim();
|
||||||
|
|
||||||
|
// TODO: when Stage0 is updated with the new --info, remove this legacy check for --version
|
||||||
|
if (string.IsNullOrEmpty(rid))
|
||||||
|
{
|
||||||
|
string version = DotNetCli.Stage0.Exec("", "--version").CaptureStdOut().Execute().StdOut;
|
||||||
|
rid = Array.Find<string>(version.Split(Environment.NewLine.ToCharArray()), (e) => e.Contains("Runtime Id:")).Replace("Runtime Id:", "").Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(rid))
|
||||||
|
{
|
||||||
|
throw new BuildFailureException("Could not find the Runtime ID from Stage0 --info or --version");
|
||||||
|
}
|
||||||
|
|
||||||
|
return rid;
|
||||||
|
}
|
||||||
|
|
||||||
[Target]
|
[Target]
|
||||||
public static BuildTargetResult CompileStage1(BuildTargetContext c)
|
public static BuildTargetResult CompileStage1(BuildTargetContext c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,7 +61,12 @@ namespace Microsoft.DotNet.Cli
|
||||||
}
|
}
|
||||||
else if (IsArg(args[lastArg], "version"))
|
else if (IsArg(args[lastArg], "version"))
|
||||||
{
|
{
|
||||||
PrintVersionInfo();
|
PrintVersion();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (IsArg(args[lastArg], "info"))
|
||||||
|
{
|
||||||
|
PrintInfo();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (IsArg(args[lastArg], "h", "help"))
|
else if (IsArg(args[lastArg], "h", "help"))
|
||||||
|
@ -129,7 +134,12 @@ namespace Microsoft.DotNet.Cli
|
||||||
.ExitCode;
|
.ExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PrintVersionInfo()
|
private static void PrintVersion()
|
||||||
|
{
|
||||||
|
Reporter.Output.WriteLine(HelpCommand.ProductVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PrintInfo()
|
||||||
{
|
{
|
||||||
HelpCommand.PrintVersionHeader();
|
HelpCommand.PrintVersionHeader();
|
||||||
|
|
||||||
|
@ -144,7 +154,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
Reporter.Output.WriteLine($" OS Name: {runtimeEnvironment.OperatingSystem}");
|
Reporter.Output.WriteLine($" OS Name: {runtimeEnvironment.OperatingSystem}");
|
||||||
Reporter.Output.WriteLine($" OS Version: {runtimeEnvironment.OperatingSystemVersion}");
|
Reporter.Output.WriteLine($" OS Version: {runtimeEnvironment.OperatingSystemVersion}");
|
||||||
Reporter.Output.WriteLine($" OS Platform: {runtimeEnvironment.OperatingSystemPlatform}");
|
Reporter.Output.WriteLine($" OS Platform: {runtimeEnvironment.OperatingSystemPlatform}");
|
||||||
Reporter.Output.WriteLine($" Runtime Id: {runtimeEnvironment.GetRuntimeIdentifier()}");
|
Reporter.Output.WriteLine($" RID: {runtimeEnvironment.GetRuntimeIdentifier()}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsArg(string candidate, string longName)
|
private static bool IsArg(string candidate, string longName)
|
||||||
|
|
|
@ -8,7 +8,7 @@ dotnet -- general driver for running the command-line commands
|
||||||
|
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
|
|
||||||
dotnet [--version] [--help] [--verbose] < command > [< args >]
|
dotnet [--version] [--info] [--help] [--verbose] < command > [< args >]
|
||||||
|
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
dotnet is a generic driver for the CLI toolchain. Invoked on its own, it will give out brief usage instructions.
|
dotnet is a generic driver for the CLI toolchain. Invoked on its own, it will give out brief usage instructions.
|
||||||
|
@ -25,6 +25,10 @@ Each specific feature is implemented as a command. In order to use the feature,
|
||||||
|
|
||||||
Print out the version of the CLI tooling
|
Print out the version of the CLI tooling
|
||||||
|
|
||||||
|
`--info`
|
||||||
|
|
||||||
|
Print out information about the CLI tooling
|
||||||
|
|
||||||
`-h, --help`
|
`-h, --help`
|
||||||
|
|
||||||
Print out a short help and a list of current commands.
|
Print out a short help and a list of current commands.
|
||||||
|
|
|
@ -17,7 +17,8 @@ Arguments:
|
||||||
|
|
||||||
Common Options (passed before the command):
|
Common Options (passed before the command):
|
||||||
-v|--verbose Enable verbose output
|
-v|--verbose Enable verbose output
|
||||||
--version Display .NET CLI Version Info
|
--version Display .NET CLI Version Number
|
||||||
|
--info Display .NET CLI Info
|
||||||
|
|
||||||
Common Commands:
|
Common Commands:
|
||||||
new Initialize a basic .NET project
|
new Initialize a basic .NET project
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue