Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public override int Execute()
        {
            if (_sdkCheckConfig != null && !string.IsNullOrEmpty(_sdkCheckConfig.CommandOutputReplacementString))
            {
                _reporter.WriteLine();
                _reporter.WriteLine(_sdkCheckConfig.CommandOutputReplacementString);
                _reporter.WriteLine();
            }
            else
            {
                try
                {
                    var productCollection = _productCollectionProvider.GetProductCollection(
                        _sdkCheckConfig?.ReleasesUri == null ? null : new Uri(_sdkCheckConfig.ReleasesUri),
                        _sdkCheckConfig?.ReleasesFilePath == null ? null : _sdkCheckConfig.ReleasesFilePath);
                    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);
        }