public override int Execute() { try { var dotnetPath = EnvironmentProvider.GetDotnetExeDirectory(); var productCollection = _productCollectionProvider.GetProductCollection(); var environmentInfo = _netBundleProvider.GetDotnetEnvironmentInfo(dotnetPath); var sdkFormatter = new SdkOutputWriter(environmentInfo.SdkInfo, productCollection, _productCollectionProvider, _reporter); var runtimeFormatter = new RuntimeOutputWriter(environmentInfo.RuntimeInfo, productCollection, _productCollectionProvider, _reporter); sdkFormatter.PrintSdkInfo(); _reporter.WriteLine(); runtimeFormatter.PrintRuntimeInfo(); _reporter.WriteLine(); _reporter.WriteLine(LocalizableStrings.CommandFooter); _reporter.WriteLine(); } catch (HostFxrResolutionException hostfxrResolutionException) { switch (hostfxrResolutionException) { case HostFxrRuntimePropertyNotSetException: throw new GracefulException(new[] { LocalizableStrings.RuntimePropertyNotFound }, new string[] { }, isUserError: false); case HostFxrNotFoundException hostFxrNotFoundException: throw new GracefulException(new[] { LocalizableStrings.HostFxrCouldNotBeLoaded }, new string[] { hostFxrNotFoundException.Message }, isUserError: false); } } return(0); }
public static string GetDotnetExeDirectory(Func <string, string> getEnvironmentVariable = null) { if (getEnvironmentVariable == null) { getEnvironmentVariable = Environment.GetEnvironmentVariable; } var environmentProvider = new EnvironmentProvider(getEnvironmentVariable); return(environmentProvider.GetDotnetExeDirectory()); }
public SdkCheckCommand( ParseResult parseResult, INETBundleProvider bundleProvider = null, IProductCollectionProvider productCollectionProvider = null, IReporter reporter = null, string dotnetRoot = null, string dotnetVersion = null) : base(parseResult) { _dotnetPath = dotnetRoot ?? EnvironmentProvider.GetDotnetExeDirectory(); var configFilePath = Path.Combine(_dotnetPath, "sdk", dotnetVersion ?? Product.Version, "sdk-check-config.json"); _sdkCheckConfig = File.Exists(configFilePath) ? JsonSerializer.Deserialize <SdkCheckConfig>(File.ReadAllText(configFilePath)) : null; _reporter = reporter ?? Reporter.Output; _netBundleProvider = bundleProvider == null ? new NETBundlesNativeWrapper() : bundleProvider; _productCollectionProvider = productCollectionProvider == null ? new ProductCollectionProvider() : productCollectionProvider; }
public override int Execute() { var dotnetPath = EnvironmentProvider.GetDotnetExeDirectory(); var productCollection = _productCollectionProvider.GetProductCollection(); var environmentInfo = _netBundleProvider.GetDotnetEnvironmentInfo(dotnetPath); var sdkFormatter = new SdkOutputWriter(environmentInfo.SdkInfo, productCollection, _productCollectionProvider, _reporter); var runtimeFormatter = new RuntimeOutputWriter(environmentInfo.RuntimeInfo, productCollection, _productCollectionProvider, _reporter); sdkFormatter.PrintSdkInfo(); _reporter.WriteLine(); runtimeFormatter.PrintRuntimeInfo(); _reporter.WriteLine(); _reporter.WriteLine(LocalizableStrings.CommandFooter); _reporter.WriteLine(); return(0); }