Beispiel #1
0
 public NuGetUpgraderConfig(
     ITracer tracer,
     LocalScalarConfig localScalarConfig,
     string feedUrl,
     string packageFeedName)
     : this(tracer, localScalarConfig)
 {
     this.FeedUrl         = feedUrl;
     this.PackageFeedName = packageFeedName;
 }
Beispiel #2
0
        /// <summary>
        /// Try to load a NuGetUpgrader from config settings.
        /// <isConfigured>Flag to indicate whether the system is configured to use a NuGetUpgrader.
        /// A NuGetUpgrader can be set as the Upgrader to use, but it might not be properly configured.
        /// </isConfigured>
        /// <Returns>True if able to load a properly configured NuGetUpgrader<Returns>
        /// </summary>
        public static bool TryCreate(
            ITracer tracer,
            PhysicalFileSystem fileSystem,
            LocalScalarConfig scalarConfig,
            ICredentialStore credentialStore,
            bool dryRun,
            bool noVerify,
            out NuGetUpgrader nuGetUpgrader,
            out bool isConfigured,
            out string error)
        {
            NuGetUpgraderConfig upgraderConfig = new NuGetUpgraderConfig(tracer, scalarConfig);

            nuGetUpgrader = null;
            isConfigured  = false;

            if (!upgraderConfig.TryLoad(out error))
            {
                nuGetUpgrader = null;
                return(false);
            }

            if (!(isConfigured = upgraderConfig.IsConfigured(out error)))
            {
                return(false);
            }

            // At this point, we have determined that the system is set up to use
            // the NuGetUpgrader

            if (!upgraderConfig.IsReady(out error))
            {
                return(false);
            }

            nuGetUpgrader = new NuGetUpgrader(
                ProcessHelper.GetCurrentProcessVersion(),
                tracer,
                fileSystem,
                dryRun,
                noVerify,
                upgraderConfig,
                ProductUpgraderInfo.GetAssetDownloadsPath(),
                credentialStore);

            return(true);
        }
Beispiel #3
0
 public NuGetUpgraderConfig(ITracer tracer, LocalScalarConfig localScalarConfig)
 {
     this.tracer      = tracer;
     this.localConfig = localScalarConfig;
 }
 public OrgNuGetUpgraderConfig(ITracer tracer, LocalScalarConfig localScalarConfig)
     : base(tracer, localScalarConfig)
 {
 }
Beispiel #5
0
        public override void Execute()
        {
            if (!ScalarPlatform.Instance.UnderConstruction.SupportsScalarConfig)
            {
                this.ReportErrorAndExit("`scalar config` is not yet implemented on this operating system.");
            }

            this.localConfig = new LocalScalarConfig();
            string error = null;

            if (this.IsMutuallyExclusiveOptionsSet(out error))
            {
                this.ReportErrorAndExit(error);
            }

            if (this.List)
            {
                Dictionary <string, string> allSettings;
                if (!this.localConfig.TryGetAllConfig(out allSettings, out error))
                {
                    this.ReportErrorAndExit(error);
                }

                const string ConfigOutputFormat = "{0}={1}";
                foreach (KeyValuePair <string, string> setting in allSettings)
                {
                    Console.WriteLine(ConfigOutputFormat, setting.Key, setting.Value);
                }
            }
            else if (!string.IsNullOrEmpty(this.KeyToDelete))
            {
                if (!ScalarPlatform.Instance.IsElevated())
                {
                    this.ReportErrorAndExit("`scalar config` must be run from an elevated command prompt when deleting settings.");
                }

                if (!this.localConfig.TryRemoveConfig(this.KeyToDelete, out error))
                {
                    this.ReportErrorAndExit(error);
                }
            }
            else if (!string.IsNullOrEmpty(this.Key))
            {
                bool valueSpecified = !string.IsNullOrEmpty(this.Value);
                if (valueSpecified)
                {
                    if (!ScalarPlatform.Instance.IsElevated())
                    {
                        this.ReportErrorAndExit("`scalar config` must be run from an elevated command prompt when configuring settings.");
                    }

                    if (!this.localConfig.TrySetConfig(this.Key, this.Value, out error))
                    {
                        this.ReportErrorAndExit(error);
                    }
                }
                else
                {
                    string valueRead = null;
                    if (!this.localConfig.TryGetConfig(this.Key, out valueRead, out error) ||
                        string.IsNullOrEmpty(valueRead))
                    {
                        this.ReportErrorAndExit(error);
                    }
                    else
                    {
                        Console.WriteLine(valueRead);
                    }
                }
            }
            else
            {
                this.ReportErrorAndExit("You must specify an option. Run `scalar config --help` for details.");
            }
        }