예제 #1
0
        public void Execute()
        {
            if (Help)
            {
                HelpCommand.ViewHelpForCommand(CommandAttribute.CommandName);
            }
            else
            {
                if (String.IsNullOrEmpty(ConfigFile))
                {
                    Settings = NuGet.Settings.LoadDefaultSettings(
                        FileSystem,
                        configFileName: null,
                        machineWideSettings: MachineWideSettings);
                }
                else
                {
                    var directory        = Path.GetDirectoryName(Path.GetFullPath(ConfigFile));
                    var configFileName   = Path.GetFileName(ConfigFile);
                    var configFileSystem = new PhysicalFileSystem(directory);

                    // Create the config file when neccessary
                    if (!configFileSystem.FileExists(configFileName) &&
                        ShouldCreateConfigFile)
                    {
                        XmlUtility.CreateDocument("configuration", configFileSystem, configFileName);
                    }

                    Settings = NuGet.Settings.LoadDefaultSettings(
                        configFileSystem,
                        configFileName,
                        MachineWideSettings);
                }

                SourceProvider = PackageSourceBuilder.CreateSourceProvider(Settings);

                // Register an additional provider for the console specific application so that the user
                // will be prompted if a proxy is set and credentials are required
                var credentialProvider = new SettingsCredentialProvider(
                    new ConsoleCredentialProvider(Console),
                    SourceProvider,
                    Console);
                HttpClient.DefaultCredentialProvider = credentialProvider;
                RepositoryFactory = new NuGet.Common.CommandLineRepositoryFactory(Console);

                // enable the V3 shim
                if (ShimControllerProvider != null)
                {
                    ShimControllerProvider.Controller.Enable(SourceProvider);
                }

                ExecuteCommand();
            }
        }
예제 #2
0
        public void Execute()
        {
            if (Help)
            {
                HelpCommand.ViewHelpForCommand(CommandAttribute.CommandName);
            }
            else
            {
                Stopwatch watch = new Stopwatch();
                watch.Start();
                if (String.IsNullOrEmpty(ConfigFile))
                {
                    Settings = NuGet.Settings.LoadDefaultSettings(
                        FileSystem,
                        configFileName: null,
                        machineWideSettings: MachineWideSettings);
                }
                else
                {
                    var directory        = Path.GetDirectoryName(Path.GetFullPath(ConfigFile));
                    var configFileName   = Path.GetFileName(ConfigFile);
                    var configFileSystem = new PhysicalFileSystem(directory);

                    // Create the config file when neccessary
                    if (!configFileSystem.FileExists(configFileName) &&
                        ShouldCreateConfigFile)
                    {
                        XmlUtility.CreateDocument("configuration", configFileSystem, configFileName);
                    }

                    Settings = NuGet.Settings.LoadDefaultSettings(
                        configFileSystem,
                        configFileName,
                        MachineWideSettings);
                }

                SourceProvider = PackageSourceBuilder.CreateSourceProvider(Settings);

                // Register an additional provider for the console specific application so that the user
                // will be prompted if a proxy is set and credentials are required
                var credentialProvider = new SettingsCredentialProvider(
                    new ConsoleCredentialProvider(Console),
                    SourceProvider,
                    Console);
                HttpClient.DefaultCredentialProvider = credentialProvider;

                ExecuteCommand();
                watch.Stop();
                DisplayExecutedTime(watch.Elapsed, CommandAttribute.CommandName);
            }
        }