2017-03-19 18:48:16 -07:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
2015-11-16 11:21:57 -08:00
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using System;
|
2017-06-05 20:51:58 -07:00
|
|
|
|
using System.Collections.Generic;
|
2018-03-23 12:40:58 -07:00
|
|
|
|
using System.IO;
|
2015-10-06 02:19:27 -07:00
|
|
|
|
using System.Linq;
|
2017-11-27 10:45:43 -08:00
|
|
|
|
using System.Runtime.InteropServices;
|
2016-04-22 14:20:50 -05:00
|
|
|
|
using System.Text;
|
2017-03-14 12:26:24 -07:00
|
|
|
|
using Microsoft.DotNet.Cli.CommandLine;
|
2017-06-05 20:51:58 -07:00
|
|
|
|
using Microsoft.DotNet.Cli.Telemetry;
|
2015-10-06 10:46:43 -07:00
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
2016-06-06 15:41:14 -07:00
|
|
|
|
using Microsoft.DotNet.Configurer;
|
2016-08-09 11:05:00 -07:00
|
|
|
|
using Microsoft.DotNet.PlatformAbstractions;
|
2017-12-04 14:13:24 -08:00
|
|
|
|
using Microsoft.DotNet.ShellShim;
|
2016-02-04 12:41:50 -08:00
|
|
|
|
using Microsoft.DotNet.Tools.Help;
|
2017-11-27 10:45:43 -08:00
|
|
|
|
using Microsoft.Extensions.EnvironmentAbstractions;
|
2016-04-14 23:33:41 -05:00
|
|
|
|
using NuGet.Frameworks;
|
2017-03-02 19:36:51 -08:00
|
|
|
|
using Command = Microsoft.DotNet.Cli.Utils.Command;
|
2017-11-27 10:45:43 -08:00
|
|
|
|
using RuntimeEnvironment = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment;
|
2018-03-07 12:39:46 -08:00
|
|
|
|
using LocalizableStrings = Microsoft.DotNet.Cli.Utils.LocalizableStrings;
|
2015-10-03 11:34:08 -07:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli
|
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
2018-03-23 12:40:58 -07:00
|
|
|
|
private static readonly string ToolPathSentinelFileName = $"{Product.Version}.toolpath.sentinel";
|
|
|
|
|
|
2015-10-03 11:34:08 -07:00
|
|
|
|
public static int Main(string[] args)
|
|
|
|
|
{
|
2015-11-28 00:28:45 -08:00
|
|
|
|
DebugHelper.HandleDebugSwitch(ref args);
|
2016-04-25 11:29:29 -07:00
|
|
|
|
|
2016-04-22 12:23:26 -07:00
|
|
|
|
new MulticoreJitActivator().TryActivateMulticoreJit();
|
2016-04-25 11:29:29 -07:00
|
|
|
|
|
2016-04-27 16:04:26 -07:00
|
|
|
|
if (Env.GetEnvironmentVariableAsBool("DOTNET_CLI_CAPTURE_TIMING", false))
|
|
|
|
|
{
|
|
|
|
|
PerfTrace.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-22 14:20:50 -05:00
|
|
|
|
InitializeProcess();
|
|
|
|
|
|
2016-01-06 02:27:16 -08:00
|
|
|
|
try
|
|
|
|
|
{
|
2016-04-27 16:04:26 -07:00
|
|
|
|
using (PerfTrace.Current.CaptureTiming())
|
|
|
|
|
{
|
2016-06-22 15:17:54 -07:00
|
|
|
|
return ProcessArgs(args);
|
2016-04-27 16:04:26 -07:00
|
|
|
|
}
|
2016-01-06 02:27:16 -08:00
|
|
|
|
}
|
2017-03-09 12:31:34 -08:00
|
|
|
|
catch (HelpException e)
|
|
|
|
|
{
|
2017-03-14 11:23:19 -07:00
|
|
|
|
Reporter.Output.WriteLine(e.Message);
|
2017-03-13 20:06:59 -07:00
|
|
|
|
return 0;
|
2017-03-09 12:31:34 -08:00
|
|
|
|
}
|
2017-01-30 14:36:44 -08:00
|
|
|
|
catch (Exception e) when (e.ShouldBeDisplayedAsError())
|
2016-01-06 02:27:16 -08:00
|
|
|
|
{
|
2017-06-05 20:51:58 -07:00
|
|
|
|
Reporter.Error.WriteLine(CommandContext.IsVerbose()
|
|
|
|
|
? e.ToString().Red().Bold()
|
2017-03-14 12:26:24 -07:00
|
|
|
|
: e.Message.Red().Bold());
|
|
|
|
|
|
|
|
|
|
var commandParsingException = e as CommandParsingException;
|
|
|
|
|
if (commandParsingException != null)
|
|
|
|
|
{
|
|
|
|
|
Reporter.Output.WriteLine(commandParsingException.HelpText);
|
|
|
|
|
}
|
2016-04-28 17:49:04 -07:00
|
|
|
|
|
2016-01-06 02:27:16 -08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
2017-03-09 07:35:06 -08:00
|
|
|
|
catch (Exception e) when (!e.ShouldBeDisplayedAsError())
|
|
|
|
|
{
|
2017-03-14 11:23:19 -07:00
|
|
|
|
Reporter.Error.WriteLine(e.ToString().Red().Bold());
|
2017-03-09 07:35:06 -08:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2016-04-27 16:04:26 -07:00
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (PerfTrace.Enabled)
|
|
|
|
|
{
|
|
|
|
|
Reporter.Output.WriteLine("Performance Summary:");
|
|
|
|
|
PerfTraceOutput.Print(Reporter.Output, PerfTrace.GetEvents());
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-06 02:27:16 -08:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-22 15:17:54 -07:00
|
|
|
|
internal static int ProcessArgs(string[] args, ITelemetry telemetryClient = null)
|
2016-01-06 02:27:16 -08:00
|
|
|
|
{
|
2015-11-01 16:21:10 -08:00
|
|
|
|
// CommandLineApplication is a bit restrictive, so we parse things ourselves here. Individual apps should use CLA.
|
2016-01-06 02:27:16 -08:00
|
|
|
|
|
|
|
|
|
var success = true;
|
2015-11-01 16:21:10 -08:00
|
|
|
|
var command = string.Empty;
|
|
|
|
|
var lastArg = 0;
|
2017-10-27 10:58:25 -07:00
|
|
|
|
TopLevelCommandParserResult topLevelCommandParserResult = TopLevelCommandParserResult.Empty;
|
2017-11-27 10:45:43 -08:00
|
|
|
|
|
2018-05-17 12:52:21 -07:00
|
|
|
|
using (INuGetCacheSentinel nugetCacheSentinel = new NuGetCacheSentinel())
|
2017-07-25 22:30:36 -07:00
|
|
|
|
using (IFirstTimeUseNoticeSentinel disposableFirstTimeUseNoticeSentinel =
|
2018-05-17 12:52:21 -07:00
|
|
|
|
new FirstTimeUseNoticeSentinel())
|
2015-10-08 14:49:39 -07:00
|
|
|
|
{
|
2017-07-25 22:30:36 -07:00
|
|
|
|
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel = disposableFirstTimeUseNoticeSentinel;
|
2018-05-17 12:52:21 -07:00
|
|
|
|
IAspNetCertificateSentinel aspNetCertificateSentinel = new AspNetCertificateSentinel();
|
2018-03-23 12:40:58 -07:00
|
|
|
|
IFileSentinel toolPathSentinel = new FileSentinel(
|
|
|
|
|
new FilePath(
|
|
|
|
|
Path.Combine(
|
|
|
|
|
CliFolderPathCalculator.DotnetUserProfileFolderPath,
|
|
|
|
|
ToolPathSentinelFileName)));
|
|
|
|
|
|
2016-06-22 15:17:54 -07:00
|
|
|
|
for (; lastArg < args.Length; lastArg++)
|
2015-12-18 16:39:43 -08:00
|
|
|
|
{
|
2016-12-15 15:13:00 -08:00
|
|
|
|
if (IsArg(args[lastArg], "d", "diagnostics"))
|
2016-06-22 15:17:54 -07:00
|
|
|
|
{
|
2017-07-27 16:34:20 -07:00
|
|
|
|
Environment.SetEnvironmentVariable(CommandContext.Variables.Verbose, bool.TrueString);
|
|
|
|
|
CommandContext.SetVerbose(true);
|
2016-06-22 15:17:54 -07:00
|
|
|
|
}
|
|
|
|
|
else if (IsArg(args[lastArg], "version"))
|
|
|
|
|
{
|
|
|
|
|
PrintVersion();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if (IsArg(args[lastArg], "info"))
|
|
|
|
|
{
|
|
|
|
|
PrintInfo();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2017-06-05 20:51:58 -07:00
|
|
|
|
else if (IsArg(args[lastArg], "h", "help") ||
|
|
|
|
|
args[lastArg] == "-?" ||
|
|
|
|
|
args[lastArg] == "/?")
|
2016-06-22 15:17:54 -07:00
|
|
|
|
{
|
|
|
|
|
HelpCommand.PrintHelp();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2017-11-17 16:03:24 -08:00
|
|
|
|
else if (args[lastArg].StartsWith("-", StringComparison.OrdinalIgnoreCase))
|
2016-06-22 15:17:54 -07:00
|
|
|
|
{
|
|
|
|
|
Reporter.Error.WriteLine($"Unknown option: {args[lastArg]}");
|
|
|
|
|
success = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// It's the command, and we're done!
|
|
|
|
|
command = args[lastArg];
|
2017-10-27 10:58:25 -07:00
|
|
|
|
if (string.IsNullOrEmpty(command))
|
|
|
|
|
{
|
|
|
|
|
command = "help";
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-11 12:27:13 -07:00
|
|
|
|
var environmentProvider = new EnvironmentProvider();
|
|
|
|
|
|
|
|
|
|
bool generateAspNetCertificate =
|
|
|
|
|
environmentProvider.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", true);
|
|
|
|
|
bool printTelemetryMessage =
|
|
|
|
|
environmentProvider.GetEnvironmentVariableAsBool("DOTNET_PRINT_TELEMETRY_MESSAGE", true);
|
|
|
|
|
bool skipFirstRunExperience =
|
|
|
|
|
environmentProvider.GetEnvironmentVariableAsBool("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", false);
|
|
|
|
|
|
2018-06-26 16:34:00 -07:00
|
|
|
|
ReportDotnetHomeUsage(environmentProvider);
|
|
|
|
|
|
2017-11-27 10:45:43 -08:00
|
|
|
|
topLevelCommandParserResult = new TopLevelCommandParserResult(command);
|
|
|
|
|
var hasSuperUserAccess = false;
|
2017-10-27 10:58:25 -07:00
|
|
|
|
if (IsDotnetBeingInvokedFromNativeInstaller(topLevelCommandParserResult))
|
2017-07-25 22:30:36 -07:00
|
|
|
|
{
|
2018-01-09 23:10:59 -08:00
|
|
|
|
aspNetCertificateSentinel = new NoOpAspNetCertificateSentinel();
|
2017-07-25 22:30:36 -07:00
|
|
|
|
firstTimeUseNoticeSentinel = new NoOpFirstTimeUseNoticeSentinel();
|
2018-05-07 16:35:29 -07:00
|
|
|
|
toolPathSentinel = new NoOpFileSentinel(exists: false);
|
2017-11-27 10:45:43 -08:00
|
|
|
|
hasSuperUserAccess = true;
|
2018-04-11 12:27:13 -07:00
|
|
|
|
|
|
|
|
|
// When running through a native installer, we want the cache expansion to happen, so
|
|
|
|
|
// we need to override this.
|
|
|
|
|
skipFirstRunExperience = false;
|
2017-07-25 22:30:36 -07:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 10:01:42 -07:00
|
|
|
|
var dotnetFirstRunConfiguration = new DotnetFirstRunConfiguration(
|
|
|
|
|
generateAspNetCertificate,
|
|
|
|
|
printTelemetryMessage,
|
|
|
|
|
skipFirstRunExperience);
|
2018-04-11 12:27:13 -07:00
|
|
|
|
|
2017-07-25 22:30:36 -07:00
|
|
|
|
ConfigureDotNetForFirstTimeUse(
|
|
|
|
|
nugetCacheSentinel,
|
|
|
|
|
firstTimeUseNoticeSentinel,
|
2018-01-09 23:10:59 -08:00
|
|
|
|
aspNetCertificateSentinel,
|
2018-03-23 12:40:58 -07:00
|
|
|
|
toolPathSentinel,
|
2018-04-11 12:27:13 -07:00
|
|
|
|
hasSuperUserAccess,
|
|
|
|
|
dotnetFirstRunConfiguration,
|
|
|
|
|
environmentProvider);
|
2017-07-25 22:30:36 -07:00
|
|
|
|
|
2016-06-22 15:17:54 -07:00
|
|
|
|
break;
|
|
|
|
|
}
|
2015-12-18 16:39:43 -08:00
|
|
|
|
}
|
2016-06-22 15:17:54 -07:00
|
|
|
|
if (!success)
|
2015-11-16 17:39:03 -08:00
|
|
|
|
{
|
2016-02-04 12:41:50 -08:00
|
|
|
|
HelpCommand.PrintHelp();
|
2016-06-22 15:17:54 -07:00
|
|
|
|
return 1;
|
2015-10-08 14:49:39 -07:00
|
|
|
|
}
|
2016-06-22 15:17:54 -07:00
|
|
|
|
|
|
|
|
|
if (telemetryClient == null)
|
2015-10-08 14:49:39 -07:00
|
|
|
|
{
|
2017-06-05 20:51:58 -07:00
|
|
|
|
telemetryClient = new Telemetry.Telemetry(firstTimeUseNoticeSentinel);
|
2015-10-08 14:49:39 -07:00
|
|
|
|
}
|
2017-06-05 20:51:58 -07:00
|
|
|
|
TelemetryEventEntry.Subscribe(telemetryClient.TrackEvent);
|
2017-10-27 10:58:25 -07:00
|
|
|
|
TelemetryEventEntry.TelemetryFilter = new TelemetryFilter(Sha256Hasher.HashWithNormalizedCasing);
|
2015-10-08 14:49:39 -07:00
|
|
|
|
}
|
2015-11-01 16:21:10 -08:00
|
|
|
|
|
2017-06-05 20:51:58 -07:00
|
|
|
|
IEnumerable<string> appArgs =
|
|
|
|
|
(lastArg + 1) >= args.Length
|
|
|
|
|
? Enumerable.Empty<string>()
|
|
|
|
|
: args.Skip(lastArg + 1).ToArray();
|
2015-11-01 16:21:10 -08:00
|
|
|
|
|
2017-07-27 16:34:20 -07:00
|
|
|
|
if (CommandContext.IsVerbose())
|
2016-02-05 12:55:09 -08:00
|
|
|
|
{
|
2016-04-27 16:04:26 -07:00
|
|
|
|
Console.WriteLine($"Telemetry is: {(telemetryClient.Enabled ? "Enabled" : "Disabled")}");
|
2016-02-05 12:55:09 -08:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-27 10:58:25 -07:00
|
|
|
|
TelemetryEventEntry.SendFiltered(topLevelCommandParserResult);
|
2016-04-27 17:28:44 -07:00
|
|
|
|
|
2016-04-22 15:01:56 -07:00
|
|
|
|
int exitCode;
|
2017-10-27 10:58:25 -07:00
|
|
|
|
if (BuiltInCommandsCatalog.Commands.TryGetValue(topLevelCommandParserResult.Command, out var builtIn))
|
2016-01-30 21:47:50 -08:00
|
|
|
|
{
|
2017-10-31 13:05:46 -07:00
|
|
|
|
var parseResult = Parser.Instance.ParseFrom($"dotnet {topLevelCommandParserResult.Command}", appArgs.ToArray());
|
|
|
|
|
if (!parseResult.Errors.Any())
|
|
|
|
|
{
|
|
|
|
|
TelemetryEventEntry.SendFiltered(parseResult);
|
|
|
|
|
}
|
2017-09-10 11:47:19 -07:00
|
|
|
|
|
2017-03-19 17:09:05 -07:00
|
|
|
|
exitCode = builtIn.Command(appArgs.ToArray());
|
2016-03-25 13:15:36 -07:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-10-03 21:40:24 -07:00
|
|
|
|
CommandResult result = Command.Create(
|
2017-10-27 10:58:25 -07:00
|
|
|
|
"dotnet-" + topLevelCommandParserResult.Command,
|
2016-10-03 21:40:24 -07:00
|
|
|
|
appArgs,
|
|
|
|
|
FrameworkConstants.CommonFrameworks.NetStandardApp15)
|
2016-03-25 13:15:36 -07:00
|
|
|
|
.Execute();
|
|
|
|
|
exitCode = result.ExitCode;
|
2016-01-30 21:47:50 -08:00
|
|
|
|
}
|
2016-03-25 13:15:36 -07:00
|
|
|
|
return exitCode;
|
2017-07-25 22:30:36 -07:00
|
|
|
|
}
|
2016-03-25 13:15:36 -07:00
|
|
|
|
|
2018-06-26 16:34:00 -07:00
|
|
|
|
private static void ReportDotnetHomeUsage(IEnvironmentProvider provider)
|
|
|
|
|
{
|
|
|
|
|
var home = provider.GetEnvironmentVariable(CliFolderPathCalculator.DotnetHomeVariableName);
|
|
|
|
|
if (string.IsNullOrEmpty(home))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Reporter.Verbose.WriteLine(
|
|
|
|
|
string.Format(
|
|
|
|
|
LocalizableStrings.DotnetCliHomeUsed,
|
|
|
|
|
home,
|
|
|
|
|
CliFolderPathCalculator.DotnetHomeVariableName));
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-27 10:58:25 -07:00
|
|
|
|
private static bool IsDotnetBeingInvokedFromNativeInstaller(TopLevelCommandParserResult parseResult)
|
2017-07-25 22:30:36 -07:00
|
|
|
|
{
|
2017-10-27 10:58:25 -07:00
|
|
|
|
return parseResult.Command == "internal-reportinstallsuccess";
|
2015-11-01 16:21:10 -08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-30 14:14:36 -07:00
|
|
|
|
private static void ConfigureDotNetForFirstTimeUse(
|
|
|
|
|
INuGetCacheSentinel nugetCacheSentinel,
|
2017-06-14 12:09:06 -04:00
|
|
|
|
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel,
|
2017-11-10 14:47:05 -08:00
|
|
|
|
IAspNetCertificateSentinel aspNetCertificateSentinel,
|
2018-03-23 12:40:58 -07:00
|
|
|
|
IFileSentinel toolPathSentinel,
|
2018-04-11 12:27:13 -07:00
|
|
|
|
bool hasSuperUserAccess,
|
|
|
|
|
DotnetFirstRunConfiguration dotnetFirstRunConfiguration,
|
|
|
|
|
IEnvironmentProvider environmentProvider)
|
2016-06-09 20:52:49 -07:00
|
|
|
|
{
|
2016-06-10 13:02:48 -07:00
|
|
|
|
using (PerfTrace.Current.CaptureTiming())
|
2016-06-09 20:52:49 -07:00
|
|
|
|
{
|
2017-03-30 14:14:36 -07:00
|
|
|
|
var nugetPackagesArchiver = new NuGetPackagesArchiver();
|
2018-05-17 12:52:21 -07:00
|
|
|
|
var environmentPath = EnvironmentPathFactory.CreateEnvironmentPath(hasSuperUserAccess, environmentProvider);
|
2017-03-30 14:14:36 -07:00
|
|
|
|
var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true);
|
|
|
|
|
var nugetCachePrimer = new NuGetCachePrimer(
|
|
|
|
|
nugetPackagesArchiver,
|
2018-05-17 12:52:21 -07:00
|
|
|
|
nugetCacheSentinel);
|
2017-11-10 14:47:05 -08:00
|
|
|
|
var aspnetCertificateGenerator = new AspNetCoreCertificateGenerator();
|
2017-03-30 14:14:36 -07:00
|
|
|
|
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
|
|
|
|
|
nugetCachePrimer,
|
|
|
|
|
nugetCacheSentinel,
|
2017-06-14 12:09:06 -04:00
|
|
|
|
firstTimeUseNoticeSentinel,
|
2017-11-10 14:47:05 -08:00
|
|
|
|
aspNetCertificateSentinel,
|
|
|
|
|
aspnetCertificateGenerator,
|
2018-03-23 12:40:58 -07:00
|
|
|
|
toolPathSentinel,
|
2018-04-11 12:27:13 -07:00
|
|
|
|
dotnetFirstRunConfiguration,
|
2017-06-19 20:52:19 -07:00
|
|
|
|
Reporter.Output,
|
2018-05-17 12:52:21 -07:00
|
|
|
|
CliFolderPathCalculator.CliFallbackFolderPath,
|
2017-11-27 10:45:43 -08:00
|
|
|
|
environmentPath);
|
2017-03-30 14:14:36 -07:00
|
|
|
|
|
|
|
|
|
dotnetConfigurer.Configure();
|
2016-06-10 13:02:48 -07:00
|
|
|
|
}
|
2016-06-09 20:52:49 -07:00
|
|
|
|
}
|
2016-04-27 16:04:26 -07:00
|
|
|
|
|
2016-04-22 14:20:50 -05:00
|
|
|
|
private static void InitializeProcess()
|
|
|
|
|
{
|
|
|
|
|
// by default, .NET Core doesn't have all code pages needed for Console apps.
|
|
|
|
|
// see the .NET Core Notes in https://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.110).aspx
|
|
|
|
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
2017-06-28 18:09:12 -07:00
|
|
|
|
|
|
|
|
|
UILanguageOverride.Setup();
|
2016-04-22 14:20:50 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-19 17:09:05 -07:00
|
|
|
|
internal static bool TryGetBuiltInCommand(string commandName, out BuiltInCommandMetadata builtInCommand)
|
2016-04-14 23:33:41 -05:00
|
|
|
|
{
|
2017-03-19 17:09:05 -07:00
|
|
|
|
return BuiltInCommandsCatalog.Commands.TryGetValue(commandName, out builtInCommand);
|
2016-04-14 23:33:41 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-28 17:17:21 -07:00
|
|
|
|
private static void PrintVersion()
|
2016-03-24 15:36:58 -05:00
|
|
|
|
{
|
2016-03-25 13:15:36 -07:00
|
|
|
|
Reporter.Output.WriteLine(Product.Version);
|
2016-03-24 15:36:58 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void PrintInfo()
|
2015-12-18 16:39:43 -08:00
|
|
|
|
{
|
2016-09-29 18:16:26 -05:00
|
|
|
|
DotnetVersionFile versionFile = DotnetFiles.VersionFileObject;
|
|
|
|
|
var commitSha = versionFile.CommitSha ?? "N/A";
|
2018-03-07 12:39:46 -08:00
|
|
|
|
Reporter.Output.WriteLine($"{LocalizableStrings.DotNetSdkInfoLabel}");
|
2018-03-07 09:40:06 -08:00
|
|
|
|
Reporter.Output.WriteLine($" Version: {Product.Version}");
|
|
|
|
|
Reporter.Output.WriteLine($" Commit: {commitSha}");
|
2016-02-18 01:09:23 -08:00
|
|
|
|
Reporter.Output.WriteLine();
|
2018-03-07 12:39:46 -08:00
|
|
|
|
Reporter.Output.WriteLine($"{LocalizableStrings.DotNetRuntimeInfoLabel}");
|
2016-04-28 16:30:32 -07:00
|
|
|
|
Reporter.Output.WriteLine($" OS Name: {RuntimeEnvironment.OperatingSystem}");
|
|
|
|
|
Reporter.Output.WriteLine($" OS Version: {RuntimeEnvironment.OperatingSystemVersion}");
|
|
|
|
|
Reporter.Output.WriteLine($" OS Platform: {RuntimeEnvironment.OperatingSystemPlatform}");
|
2016-09-30 12:00:37 -05:00
|
|
|
|
Reporter.Output.WriteLine($" RID: {GetDisplayRid(versionFile)}");
|
2016-11-20 10:24:01 -08:00
|
|
|
|
Reporter.Output.WriteLine($" Base Path: {ApplicationEnvironment.ApplicationBasePath}");
|
2015-12-18 16:39:43 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static bool IsArg(string candidate, string longName)
|
|
|
|
|
{
|
|
|
|
|
return IsArg(candidate, shortName: null, longName: longName);
|
2015-10-08 14:49:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-01 16:21:10 -08:00
|
|
|
|
private static bool IsArg(string candidate, string shortName, string longName)
|
2015-10-08 14:49:39 -07:00
|
|
|
|
{
|
2017-11-17 16:03:24 -08:00
|
|
|
|
return (shortName != null && candidate.Equals("-" + shortName, StringComparison.OrdinalIgnoreCase)) ||
|
|
|
|
|
(longName != null && candidate.Equals("--" + longName, StringComparison.OrdinalIgnoreCase));
|
2015-10-06 02:19:27 -07:00
|
|
|
|
}
|
2016-04-22 15:01:56 -07:00
|
|
|
|
|
2016-09-30 12:00:37 -05:00
|
|
|
|
private static string GetDisplayRid(DotnetVersionFile versionFile)
|
2016-02-18 01:09:23 -08:00
|
|
|
|
{
|
2016-09-30 12:00:37 -05:00
|
|
|
|
FrameworkDependencyFile fxDepsFile = new FrameworkDependencyFile();
|
2016-04-22 15:01:56 -07:00
|
|
|
|
|
2016-09-30 12:00:37 -05:00
|
|
|
|
string currentRid = RuntimeEnvironment.GetRuntimeIdentifier();
|
2016-04-22 15:01:56 -07:00
|
|
|
|
|
2017-10-27 10:58:25 -07:00
|
|
|
|
// if the current RID isn't supported by the shared framework, display the RID the CLI was
|
2016-09-30 12:00:37 -05:00
|
|
|
|
// built with instead, so the user knows which RID they should put in their "runtimes" section.
|
|
|
|
|
return fxDepsFile.IsRuntimeSupported(currentRid) ?
|
|
|
|
|
currentRid :
|
|
|
|
|
versionFile.BuildRid;
|
2016-02-18 01:09:23 -08:00
|
|
|
|
}
|
2015-10-03 11:34:08 -07:00
|
|
|
|
}
|
|
|
|
|
}
|