public MsbuildIntegrationTestFixture() { _cliDirectory = TestDotnetCLiUtility.CopyAndPatchLatestDotnetCli(); var dotnetExecutableName = RuntimeEnvironmentHelper.IsWindows ? "dotnet.exe" : "dotnet"; TestDotnetCli = Path.Combine(_cliDirectory, dotnetExecutableName); var sdkPath = Directory.EnumerateDirectories(Path.Combine(_cliDirectory, "sdk")) .Where(d => !string.Equals(Path.GetFileName(d), "NuGetFallbackFolder", StringComparison.OrdinalIgnoreCase)) .Single(); MsBuildSdksPath = Path.Combine(sdkPath, "Sdks"); _templateDirectory = new SimpleTestPathContext(); TestDotnetCLiUtility.WriteGlobalJson(_templateDirectory.WorkingDirectory); // some project templates use implicit packages. For example, class libraries targeting netstandard2.0 // will have an implicit package reference for NETStandard.Library, and its dependencies. // .NET Core SDK 3.0 and later no longer ship these packages in a NuGetFallbackFolder. Therefore, we need // to be able to download these packages. We'll download it once into the template cache's global packages // folder, and then use that as a local source for individual tests, to minimise network access. var addSourceArgs = new AddSourceArgs() { Configfile = _templateDirectory.NuGetConfig, Name = "nuget.org", Source = "https://api.nuget.org/v3/index.json" }; AddSourceRunner.Run(addSourceArgs, () => NullLogger.Instance); _processEnvVars.Add("MSBuildSDKsPath", MsBuildSdksPath); _processEnvVars.Add("UseSharedCompilation", "false"); _processEnvVars.Add("DOTNET_MULTILEVEL_LOOKUP", "0"); _processEnvVars.Add("MSBUILDDISABLENODEREUSE ", "true"); }
public void Add(string configFile, NugetPackageSource packageSource) { var addSourceArgs = new AddSourceArgs { Configfile = configFile, Name = packageSource.Name, Password = packageSource.Password.GetOrElse(string.Empty), Source = packageSource.Source, Username = packageSource.Username.GetOrElse(string.Empty), ValidAuthenticationTypes = packageSource.ValidAuthenticationTypes.GetOrElse(string.Empty), StorePasswordInClearText = packageSource.StorePasswordInClearText, }; CreateMinimalConfigIfNotExistOrIsEmpty(configFile); AddSourceRunner.Run(addSourceArgs, _getLogger); }
internal SimpleTestPathContext CreateSimpleTestPathContext() { var simpleTestPathContext = new SimpleTestPathContext(); TestDotnetCLiUtility.WriteGlobalJson(simpleTestPathContext.WorkingDirectory); // Some template and TFM combinations need packages, for example NETStandard.Library. // The template cache should have downloaded it already, so use the template cache's // global packages folder as a local source. var addSourceArgs = new AddSourceArgs() { Configfile = simpleTestPathContext.NuGetConfig, Name = "template", Source = _templateDirectory.UserPackagesFolder }; AddSourceRunner.Run(addSourceArgs, () => NullLogger.Instance); return(simpleTestPathContext); }
internal static void Register(CommandLineApplication app, Func <ILogger> getLogger) { app.Command("add", AddCmd => { AddCmd.Command("source", SourceCmd => { CommandArgument Source = SourceCmd.Argument( "PackageSourcePath", Strings.SourcesCommandSourceDescription); CommandOption name = SourceCmd.Option( "-n|--name", Strings.SourcesCommandNameDescription, CommandOptionType.SingleValue); CommandOption username = SourceCmd.Option( "-u|--username", Strings.SourcesCommandUserNameDescription, CommandOptionType.SingleValue); CommandOption password = SourceCmd.Option( "-p|--password", Strings.SourcesCommandPasswordDescription, CommandOptionType.SingleValue); CommandOption storePasswordInClearText = SourceCmd.Option( "--store-password-in-clear-text", Strings.SourcesCommandStorePasswordInClearTextDescription, CommandOptionType.NoValue); CommandOption validAuthenticationTypes = SourceCmd.Option( "--valid-authentication-types", Strings.SourcesCommandValidAuthenticationTypesDescription, CommandOptionType.SingleValue); CommandOption configfile = SourceCmd.Option( "--configfile", Strings.Option_ConfigFile, CommandOptionType.SingleValue); SourceCmd.HelpOption("-h|--help"); SourceCmd.Description = Strings.AddSourceCommandDescription; SourceCmd.OnExecute(() => { var args = new AddSourceArgs() { Source = Source.Value, Name = name.Value(), Username = username.Value(), Password = password.Value(), StorePasswordInClearText = storePasswordInClearText.HasValue(), ValidAuthenticationTypes = validAuthenticationTypes.Value(), Configfile = configfile.Value(), }; AddSourceRunner.Run(args, getLogger); return(0); }); }); AddCmd.HelpOption("-h|--help"); AddCmd.Description = Strings.Add_Description; AddCmd.OnExecute(() => { app.ShowHelp("add"); return(0); }); }); }
public override void ExecuteCommand() { if (SourceProvider == null) { throw new InvalidOperationException(LocalizedResourceManager.GetString("Error_SourceProviderIsNull")); } SourcesAction action = SourcesAction.None; var actionArg = Arguments.FirstOrDefault(); if (string.IsNullOrEmpty(actionArg)) { action = SourcesAction.List; } else { if (!Enum.TryParse <SourcesAction>(actionArg, ignoreCase: true, out action)) { Console.WriteLine(LocalizedResourceManager.GetString("SourcesCommandUsageSummary")); } } switch (action) { case SourcesAction.Add: var addArgs = new AddSourceArgs() { Name = Name, Source = Source, Username = Username, Password = Password, StorePasswordInClearText = StorePasswordInClearText, ValidAuthenticationTypes = ValidAuthenticationTypes, Configfile = ConfigFile }; AddSourceRunner.Run(addArgs, () => Console); break; case SourcesAction.Update: var updateSourceArgs = new UpdateSourceArgs() { Name = Name, Source = Source, Username = Username, Password = Password, StorePasswordInClearText = StorePasswordInClearText, ValidAuthenticationTypes = ValidAuthenticationTypes, Configfile = ConfigFile }; UpdateSourceRunner.Run(updateSourceArgs, () => Console); break; case SourcesAction.Remove: var removeSourceArgs = new RemoveSourceArgs() { Name = Name, Configfile = ConfigFile }; RemoveSourceRunner.Run(removeSourceArgs, () => Console); break; case SourcesAction.Disable: var disableSourceArgs = new DisableSourceArgs() { Name = Name, Configfile = ConfigFile }; DisableSourceRunner.Run(disableSourceArgs, () => Console); break; case SourcesAction.Enable: var enableSourceArgs = new EnableSourceArgs() { Name = Name, Configfile = ConfigFile }; EnableSourceRunner.Run(enableSourceArgs, () => Console); break; case SourcesAction.List: var listSourceArgs = new ListSourceArgs() { Configfile = ConfigFile, Format = Format.ToString() }; ListSourceRunner.Run(listSourceArgs, () => Console); break; } }
internal static void Register(CommandLineApplication app, Func <ILogger> getLogger) { app.Command("add", AddCmd => { AddCmd.Command("source", SourceCmd => { CommandArgument Source = SourceCmd.Argument( "PackageSourcePath", Strings.SourcesCommandSourceDescription); CommandOption name = SourceCmd.Option( "-n|--name", Strings.SourcesCommandNameDescription, CommandOptionType.SingleValue); CommandOption username = SourceCmd.Option( "-u|--username", Strings.SourcesCommandUsernameDescription, CommandOptionType.SingleValue); CommandOption password = SourceCmd.Option( "-p|--password", Strings.SourcesCommandPasswordDescription, CommandOptionType.SingleValue); CommandOption storePasswordInClearText = SourceCmd.Option( "--store-password-in-clear-text", Strings.SourcesCommandStorePasswordInClearTextDescription, CommandOptionType.NoValue); CommandOption validAuthenticationTypes = SourceCmd.Option( "--valid-authentication-types", Strings.SourcesCommandValidAuthenticationTypesDescription, CommandOptionType.SingleValue); CommandOption configfile = SourceCmd.Option( "--configfile", Strings.Option_ConfigFile, CommandOptionType.SingleValue); SourceCmd.HelpOption("-h|--help"); SourceCmd.Description = Strings.AddSourceCommandDescription; SourceCmd.OnExecute(() => { var args = new AddSourceArgs() { Source = Source.Value, Name = name.Value(), Username = username.Value(), Password = password.Value(), StorePasswordInClearText = storePasswordInClearText.HasValue(), ValidAuthenticationTypes = validAuthenticationTypes.Value(), Configfile = configfile.Value(), }; AddSourceRunner.Run(args, getLogger); return(0); }); }); AddCmd.Command("client-cert", ClientCertCmd => { CommandOption packagesource = ClientCertCmd.Option( "-s|--package-source", Strings.Option_PackageSource, CommandOptionType.SingleValue); CommandOption path = ClientCertCmd.Option( "--path", Strings.Option_Path, CommandOptionType.SingleValue); CommandOption password = ClientCertCmd.Option( "--password", Strings.Option_Password, CommandOptionType.SingleValue); CommandOption storepasswordincleartext = ClientCertCmd.Option( "--store-password-in-clear-text", Strings.Option_StorePasswordInClearText, CommandOptionType.NoValue); CommandOption storelocation = ClientCertCmd.Option( "--store-location", Strings.Option_StoreLocation, CommandOptionType.SingleValue); CommandOption storename = ClientCertCmd.Option( "--store-name", Strings.Option_StoreName, CommandOptionType.SingleValue); CommandOption findby = ClientCertCmd.Option( "--find-by", Strings.Option_FindBy, CommandOptionType.SingleValue); CommandOption findvalue = ClientCertCmd.Option( "--find-value", Strings.Option_FindValue, CommandOptionType.SingleValue); CommandOption force = ClientCertCmd.Option( "-f|--force", Strings.Option_Force, CommandOptionType.NoValue); CommandOption configfile = ClientCertCmd.Option( "--configfile", Strings.Option_ConfigFile, CommandOptionType.SingleValue); ClientCertCmd.HelpOption("-h|--help"); ClientCertCmd.Description = Strings.AddClientCertCommandDescription; ClientCertCmd.OnExecute(() => { var args = new AddClientCertArgs() { PackageSource = packagesource.Value(), Path = path.Value(), Password = password.Value(), StorePasswordInClearText = storepasswordincleartext.HasValue(), StoreLocation = storelocation.Value(), StoreName = storename.Value(), FindBy = findby.Value(), FindValue = findvalue.Value(), Force = force.HasValue(), Configfile = configfile.Value(), }; AddClientCertRunner.Run(args, getLogger); return(0); }); }); AddCmd.HelpOption("-h|--help"); AddCmd.Description = Strings.Add_Description; AddCmd.OnExecute(() => { app.ShowHelp("add"); return(0); }); }); }