コード例 #1
0
        private static void Main(string[] args)
        {
            var options = new DeploymentOptions();

            if (Parser.Default.ParseArguments(args, options))
            {
                var executeDeployment = true;

                _AcknowledgeArguments(options);

                var hostsEntries = options.HostsFileEntryValues();
                if (hostsEntries.Any())
                {
                    var hostsUpdater = new FileUpdaters.HostsFile();

                    if (options.RemoveHostsEntries)
                    {
                        hostsUpdater.RemoveHostsEntries(hostsEntries);
                        executeDeployment = false;
                    }
                    else
                    {
                        hostsUpdater.AddHostsEntries(hostsEntries);
                    }
                }

                // check to see if the deployment should be executed, it may be aborted by above steps.
                if (executeDeployment)
                {
                    var additionalCapabilities = new Dictionary <string, string>
                    {
                        { "TestSettingsFile", options.TestSettingsFile },
                        { "TestSettingsStore", options.TestSettingsStore }
                    };

                    foreach (var capability in options.GetAdditionalCapabilities())
                    {
                        additionalCapabilities.Add(capability.Key, capability.Value);
                    }
                    var previousAppSettings = _UpdateDeploymentConfig(additionalCapabilities);
                    UpdaterFacade.UpdateSettingsConfig(options.TestAssembly);
                    //reset the deployment app config to its original state
                    //this is to avoid future runs of the app making unintended
                    //changes to the settings
                    _ResetDeploymentConfig(previousAppSettings);
                }
            }
        }
コード例 #2
0
        private static void _AcknowledgeArguments(DeploymentOptions options)
        {
            Console.WriteLine("\r\n==== Specified options begin ====");
            // get all public static properties of DeploymentOptions type
            var propertyInfos = typeof(DeploymentOptions).GetProperties();

            //print them all to the console
            foreach (var propertyInfo in propertyInfos)
            {
                if (propertyInfo.Name != "AdditionalCapabilitiesRaw")
                {
                    Console.WriteLine("{0}: {1}", propertyInfo.Name, propertyInfo.GetValue(options));
                }
            }
            foreach (var capability in options.GetAdditionalCapabilities())
            {
                Console.WriteLine("{0}: {1}", capability.Key, capability.Value);
            }
            Console.WriteLine("==== Specified options end ======\r\n");
        }