diff --git a/scripts/cli-test-env.sh b/scripts/cli-test-env.sh index 888200d32..556e032f7 100755 --- a/scripts/cli-test-env.sh +++ b/scripts/cli-test-env.sh @@ -16,7 +16,7 @@ REPO_ROOT="$( cd -P "$( dirname "$SOURCE" )/../" && pwd )" uname=$(uname) if [ "$(uname)" = "Darwin" ] then - RID=osx.10.13-x64 + RID=osx-x64 else RID=linux-x64 fi diff --git a/src/dotnet/ToolPackage/IProjectRestorer.cs b/src/dotnet/ToolPackage/IProjectRestorer.cs index 86aa06e57..0546c399a 100644 --- a/src/dotnet/ToolPackage/IProjectRestorer.cs +++ b/src/dotnet/ToolPackage/IProjectRestorer.cs @@ -8,11 +8,9 @@ namespace Microsoft.DotNet.ToolPackage { internal interface IProjectRestorer { - void Restore( - FilePath project, + void Restore(FilePath project, DirectoryPath assetJsonOutput, FilePath? nugetConfig = null, - string source = null, string verbosity = null); } } diff --git a/src/dotnet/ToolPackage/IToolPackageInstaller.cs b/src/dotnet/ToolPackage/IToolPackageInstaller.cs index d54de5460..c4b8f9bfc 100644 --- a/src/dotnet/ToolPackage/IToolPackageInstaller.cs +++ b/src/dotnet/ToolPackage/IToolPackageInstaller.cs @@ -10,13 +10,12 @@ namespace Microsoft.DotNet.ToolPackage { internal interface IToolPackageInstaller { - IToolPackage InstallPackage( - PackageId packageId, + IToolPackage InstallPackage(PackageId packageId, VersionRange versionRange = null, string targetFramework = null, FilePath? nugetConfig = null, DirectoryPath? rootConfigDirectory = null, - string source = null, + string[] additionalFeeds = null, string verbosity = null); } } diff --git a/src/dotnet/ToolPackage/ToolPackageInstaller.cs b/src/dotnet/ToolPackage/ToolPackageInstaller.cs index 355dabc49..9e3fb29dd 100644 --- a/src/dotnet/ToolPackage/ToolPackageInstaller.cs +++ b/src/dotnet/ToolPackage/ToolPackageInstaller.cs @@ -30,13 +30,12 @@ namespace Microsoft.DotNet.ToolPackage _offlineFeed = offlineFeed ?? new DirectoryPath(new CliFolderPathCalculator().CliFallbackFolderPath); } - public IToolPackage InstallPackage( - PackageId packageId, + public IToolPackage InstallPackage(PackageId packageId, VersionRange versionRange = null, string targetFramework = null, FilePath? nugetConfig = null, DirectoryPath? rootConfigDirectory = null, - string source = null, + string[] additionalFeeds = null, string verbosity = null) { var packageRootDirectory = _store.GetRootPackageDirectory(packageId); @@ -55,7 +54,8 @@ namespace Microsoft.DotNet.ToolPackage versionRange: versionRange, targetFramework: targetFramework ?? BundledTargetFramework.GetTargetFrameworkMoniker(), restoreDirectory: stageDirectory, - rootConfigDirectory: rootConfigDirectory); + rootConfigDirectory: rootConfigDirectory, + additionalFeeds: additionalFeeds); try { @@ -63,8 +63,7 @@ namespace Microsoft.DotNet.ToolPackage tempProject, stageDirectory, nugetConfig, - source, - verbosity); + verbosity: verbosity); } finally { @@ -113,12 +112,12 @@ namespace Microsoft.DotNet.ToolPackage }); } - private FilePath CreateTempProject( - PackageId packageId, + private FilePath CreateTempProject(PackageId packageId, VersionRange versionRange, string targetFramework, DirectoryPath restoreDirectory, - DirectoryPath? rootConfigDirectory) + DirectoryPath? rootConfigDirectory, + string[] additionalFeeds) { var tempProject = _tempProject ?? new DirectoryPath(Path.GetTempPath()) .WithSubDirectories(Path.GetRandomFileName()) @@ -141,8 +140,7 @@ namespace Microsoft.DotNet.ToolPackage new XElement("RestoreRootConfigDirectory", rootConfigDirectory?.Value ?? Directory.GetCurrentDirectory()), // config file probing start directory new XElement("DisableImplicitFrameworkReferences", "true"), // no Microsoft.NETCore.App in tool folder new XElement("RestoreFallbackFolders", "clear"), // do not use fallbackfolder, tool package need to be copied to tool folder - new XElement("RestoreAdditionalProjectSources", // use fallbackfolder as feed to enable offline - Directory.Exists(_offlineFeed.Value) ? _offlineFeed.Value : string.Empty), + new XElement("RestoreAdditionalProjectSources", JoinSourceAndOfflineCache(additionalFeeds)), new XElement("RestoreAdditionalProjectFallbackFolders", string.Empty), // block other new XElement("RestoreAdditionalProjectFallbackFoldersExcludes", string.Empty), // block other new XElement("DisableImplicitNuGetFallbackFolder", "true")), // disable SDK side implicit NuGetFallbackFolder @@ -157,5 +155,22 @@ namespace Microsoft.DotNet.ToolPackage File.WriteAllText(tempProject.Value, tempProjectContent.ToString()); return tempProject; } + + private string JoinSourceAndOfflineCache(string[] additionalFeeds) + { + var feeds = new List(); + if (additionalFeeds != null) + { + feeds.AddRange(additionalFeeds); + } + + // use fallbackfolder as feed to enable offline + if (Directory.Exists(_offlineFeed.Value)) + { + feeds.Add(_offlineFeed.ToXmlEncodeString()); + } + + return string.Join(";", feeds); + } } } diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommand.cs b/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommand.cs index f0fec0a1d..36d1d1ab5 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommand.cs +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommand.cs @@ -32,7 +32,7 @@ namespace Microsoft.DotNet.Tools.Install.Tool private readonly string _packageVersion; private readonly string _configFilePath; private readonly string _framework; - private readonly string _source; + private readonly string[] _source; private readonly bool _global; private readonly string _verbosity; private readonly string _toolPath; @@ -55,7 +55,7 @@ namespace Microsoft.DotNet.Tools.Install.Tool _packageVersion = appliedCommand.ValueOrDefault("version"); _configFilePath = appliedCommand.ValueOrDefault("configfile"); _framework = appliedCommand.ValueOrDefault("framework"); - _source = appliedCommand.ValueOrDefault("source"); + _source = appliedCommand.ValueOrDefault("source-feed"); _global = appliedCommand.ValueOrDefault("global"); _verbosity = appliedCommand.SingleArgumentOrDefault("verbosity"); _toolPath = appliedCommand.SingleArgumentOrDefault("tool-path"); @@ -137,7 +137,7 @@ namespace Microsoft.DotNet.Tools.Install.Tool versionRange: versionRange, targetFramework: _framework, nugetConfig: configFile, - source: _source, + additionalFeeds: _source, verbosity: _verbosity); foreach (var command in package.Commands) diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommandParser.cs b/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommandParser.cs index 2d5e980a0..6bb80d417 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommandParser.cs +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommandParser.cs @@ -32,10 +32,10 @@ namespace Microsoft.DotNet.Cli LocalizableStrings.ConfigFileOptionDescription, Accept.ExactlyOneArgument()), Create.Option( - "--source", - LocalizableStrings.SourceOptionDescription, - Accept.ExactlyOneArgument() - .With(name: LocalizableStrings.SourceOptionName)), + "--source-feed", + LocalizableStrings.SourceFeedOptionDescription, + Accept.OneOrMoreArguments() + .With(name: LocalizableStrings.SourceFeedOptionName)), Create.Option( "-f|--framework", LocalizableStrings.FrameworkOptionDescription, diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/LocalizableStrings.resx b/src/dotnet/commands/dotnet-install/dotnet-install-tool/LocalizableStrings.resx index d92981706..c970ea1cf 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/LocalizableStrings.resx +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/LocalizableStrings.resx @@ -129,11 +129,11 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during installation. + + Adds an additional NuGet package source to use during installation. - - SOURCE + + SOURCE_FEED Installs a tool for use on the command line. diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/ProjectRestorer.cs b/src/dotnet/commands/dotnet-install/dotnet-install-tool/ProjectRestorer.cs index 5ba8a177b..64a382d1e 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/ProjectRestorer.cs +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/ProjectRestorer.cs @@ -26,11 +26,9 @@ namespace Microsoft.DotNet.Tools.Install.Tool _forceOutputRedirection = reporter != null; } - public void Restore( - FilePath project, + public void Restore(FilePath project, DirectoryPath assetJsonOutput, FilePath? nugetConfig = null, - string source = null, string verbosity = null) { var argsToPassToRestore = new List(); @@ -42,12 +40,6 @@ namespace Microsoft.DotNet.Tools.Install.Tool argsToPassToRestore.Add(nugetConfig.Value.Value); } - if (source != null) - { - argsToPassToRestore.Add("--source"); - argsToPassToRestore.Add(source); - } - argsToPassToRestore.AddRange(new List { "--runtime", diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.cs.xlf index dee3715a2..019e0c5c4 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.cs.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.cs.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - Určuje zdroj balíčku NuGet, který se použije při instalaci. - - - - SOURCE - SOURCE - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Nástroj {1} (verze {2}) byl úspěšně nainstalován. Umístění překrytí pro přístup k nástroji + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.de.xlf index 8b73638d1..58227cfb8 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.de.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.de.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - Gibt eine NuGet-Paketquelle für die Installation an. - - - - SOURCE - SOURCE - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Das Tool "{1}" (Version "{2}") wurde erfolgreich installiert. Shim-Speicherort für Toolzugriff + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.es.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.es.xlf index 607fd3532..774e3968c 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.es.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.es.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - Especifica el origen de un paquete NuGet para usarlo durante la instalación. - - - - SOURCE - ORIGEN - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ La herramienta "{1}" (versión "{2}") se instaló correctamente. Ubicación de las correcciones de compatibilidad (shim) para acceder a la herramienta + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.fr.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.fr.xlf index 05af1d413..cdf3f021c 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.fr.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.fr.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - Spécifie un package NuGet source à utiliser durant l'installation. - - - - SOURCE - SOURCE - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ L'outil '{1}' (version '{2}') a été installé. Emplacement de shim pour accéder à l'outil + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.it.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.it.xlf index 75cb15796..c42d1cc40 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.it.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.it.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - Consente di specificare un'origine pacchetto NuGet da usare durante l'installazione. - - - - SOURCE - ORIGINE - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Lo strumento '{1}' (versione '{2}') è stato installato. Percorso dello shim per accedere allo strumento + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ja.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ja.xlf index 0151530f9..9fa3c5928 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ja.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ja.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - インストール中に使用する NuGet パッケージを指定します。 - - - - SOURCE - SOURCE - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed. ツールにアクセスする shim の場所 + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ko.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ko.xlf index ebcf4f62e..e7d4dbd9e 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ko.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ko.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - 설치 중 사용할 NuGet 패키지 소스를 지정합니다. - - - - SOURCE - SOURCE - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed. 도구에 액세스하는 shim 위치 + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pl.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pl.xlf index 007619047..2d7d4f93f 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pl.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pl.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - Określa źródło pakietu NuGet do użycia podczas instalacji. - - - - SOURCE - ŹRÓDŁO - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Pomyślnie zainstalowano narzędzie „{1}” (wersja: „{2}”). Lokalizacja podkładki na potrzeby dostępu do narzędzia + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pt-BR.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pt-BR.xlf index e9e11e63d..0dc50e9a1 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.pt-BR.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - Especifica uma origem do pacote NuGet a ser usada durante a instalação. - - - - SOURCE - ORIGEM - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ A ferramenta '{1}' (versão '{2}') foi instalada com êxito. Local do shim para acessar a ferramenta + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ru.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ru.xlf index 4b8c24824..42eb6fd3d 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ru.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.ru.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - Задает источник пакета NuGet, используемый во время установки. - - - - SOURCE - SOURCE - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed. Расположение оболочки совместимости для доступа к инструменту + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.tr.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.tr.xlf index e9c3fe176..2bd6bf5bb 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.tr.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.tr.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - Yükleme sırasında kullanılacak bir NuGet paket kaynağı belirtir. - - - - SOURCE - SOURCE - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed. Araca erişmek için dolgu konumu + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hans.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hans.xlf index 2e396c5d8..63d1210de 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hans.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - 指定安装期间使用的 NuGet 包源。 - - - - SOURCE - SOURCE - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed. 填充程序访问工具的位置 + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hant.xlf b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hant.xlf index 3e2ddc977..48bd8e3e5 100644 --- a/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.zh-Hant.xlf @@ -2,16 +2,6 @@ - - Specifies a NuGet package source to use during installation. - 指定於安裝期間要使用的 NuGet 套件來源。 - - - - SOURCE - SOURCE - - You can invoke the tool using the following command: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed. 存取工具的填充碼位置 + + Adds an additional NuGet package source to use during installation. + Adds an additional NuGet package source to use during installation. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/LocalizableStrings.resx b/src/dotnet/commands/dotnet-update/tool/LocalizableStrings.resx index 73612c265..c6505018e 100644 --- a/src/dotnet/commands/dotnet-update/tool/LocalizableStrings.resx +++ b/src/dotnet/commands/dotnet-update/tool/LocalizableStrings.resx @@ -129,11 +129,11 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. + + Adds an additional NuGet package source to use during update. - - SOURCE + + SOURCE_FEED Updates a tool to the latest stable version for use. diff --git a/src/dotnet/commands/dotnet-update/tool/UpdateToolCommand.cs b/src/dotnet/commands/dotnet-update/tool/UpdateToolCommand.cs index d17ba3b2c..9bfe52902 100644 --- a/src/dotnet/commands/dotnet-update/tool/UpdateToolCommand.cs +++ b/src/dotnet/commands/dotnet-update/tool/UpdateToolCommand.cs @@ -32,7 +32,7 @@ namespace Microsoft.DotNet.Tools.Update.Tool private readonly PackageId _packageId; private readonly string _configFilePath; private readonly string _framework; - private readonly string _source; + private readonly string[] _additionalFeeds; private readonly bool _global; private readonly string _verbosity; private readonly string _toolPath; @@ -52,7 +52,7 @@ namespace Microsoft.DotNet.Tools.Update.Tool _packageId = new PackageId(appliedCommand.Arguments.Single()); _configFilePath = appliedCommand.ValueOrDefault("configfile"); _framework = appliedCommand.ValueOrDefault("framework"); - _source = appliedCommand.ValueOrDefault("source"); + _additionalFeeds = appliedCommand.ValueOrDefault("source-feed"); _global = appliedCommand.ValueOrDefault("global"); _verbosity = appliedCommand.SingleArgumentOrDefault("verbosity"); _toolPath = appliedCommand.SingleArgumentOrDefault("tool-path"); @@ -136,7 +136,7 @@ namespace Microsoft.DotNet.Tools.Update.Tool packageId: _packageId, targetFramework: _framework, nugetConfig: configFile, - source: _source, + additionalFeeds: _additionalFeeds, verbosity: _verbosity); foreach (CommandSettings command in newInstalledPackage.Commands) diff --git a/src/dotnet/commands/dotnet-update/tool/UpdateToolCommandParser.cs b/src/dotnet/commands/dotnet-update/tool/UpdateToolCommandParser.cs index b54157c22..00f21ceb1 100644 --- a/src/dotnet/commands/dotnet-update/tool/UpdateToolCommandParser.cs +++ b/src/dotnet/commands/dotnet-update/tool/UpdateToolCommandParser.cs @@ -28,10 +28,10 @@ namespace Microsoft.DotNet.Cli LocalizableStrings.ConfigFileOptionDescription, Accept.ExactlyOneArgument()), Create.Option( - "--source", - LocalizableStrings.SourceOptionDescription, - Accept.ExactlyOneArgument() - .With(name: LocalizableStrings.SourceOptionName)), + "--source-feed", + LocalizableStrings.SourceFeedOptionDescription, + Accept.OneOrMoreArguments() + .With(name: LocalizableStrings.SourceFeedOptionName)), Create.Option( "-f|--framework", LocalizableStrings.FrameworkOptionDescription, diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.cs.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.cs.xlf index dce83fccb..07d7de0a9 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.cs.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.cs.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.de.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.de.xlf index 2ebfc47ae..6fc9de496 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.de.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.de.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.es.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.es.xlf index cf2a1d069..49c987ee1 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.es.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.es.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.fr.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.fr.xlf index 39f023539..77c9413aa 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.fr.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.fr.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.it.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.it.xlf index d4ac17afe..107e14848 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.it.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.it.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ja.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ja.xlf index 8f8ed7a69..13d09a397 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ja.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ja.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ko.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ko.xlf index a26b131ee..a280e9ddb 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ko.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ko.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.pl.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.pl.xlf index acc3e3ea5..618b1d1f8 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.pl.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.pl.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.pt-BR.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.pt-BR.xlf index 85d3a25cf..71b3448d2 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.pt-BR.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.pt-BR.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ru.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ru.xlf index 3863fd8bf..60d549909 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ru.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.ru.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.tr.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.tr.xlf index b2425f5df..fd9712581 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.tr.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.tr.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.zh-Hans.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.zh-Hans.xlf index 8f413823a..6e8e4c2d4 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.zh-Hans.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.zh-Hans.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.zh-Hant.xlf b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.zh-Hant.xlf index a64e6a4ab..9e073a7db 100644 --- a/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.zh-Hant.xlf +++ b/src/dotnet/commands/dotnet-update/tool/xlf/LocalizableStrings.zh-Hant.xlf @@ -22,16 +22,6 @@ Version of the tool package in NuGet. - - Specifies a NuGet package source to use during update. - Specifies a NuGet package source to use during update. - - - - SOURCE - SOURCE - - Updates a tool to the latest stable version for use. Updates a tool to the latest stable version for use. @@ -102,6 +92,16 @@ Tool '{0}' failed to update due to the following: + + Adds an additional NuGet package source to use during update. + Adds an additional NuGet package source to use during update. + + + + SOURCE_FEED + SOURCE_FEED + + \ No newline at end of file diff --git a/test/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs b/test/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs index d03af3951..848849ba4 100644 --- a/test/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs +++ b/test/Microsoft.DotNet.ToolPackage.Tests/ToolPackageInstallerTests.cs @@ -46,7 +46,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests [Theory] [InlineData(false)] [InlineData(true)] - public void GivenOfflineFeedInstallSuceeds(bool testMockBehaviorIsInSync) + public void GivenOfflineFeedInstallSucceeds(bool testMockBehaviorIsInSync) { var (store, installer, reporter, fileSystem) = Setup( useMock: testMockBehaviorIsInSync, @@ -63,6 +63,30 @@ namespace Microsoft.DotNet.ToolPackage.Tests package.Uninstall(); } + [Theory] + [InlineData(false)] + [InlineData(true)] + public void GivenAEmptySourceAndOfflineFeedInstallSucceeds(bool testMockBehaviorIsInSync) + { + var emptySource = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + Directory.CreateDirectory(emptySource); + + var (store, installer, reporter, fileSystem) = Setup( + useMock: testMockBehaviorIsInSync, + offlineFeed: new DirectoryPath(GetTestLocalFeedPath()), + feeds: GetOfflineMockFeed()); + + var package = installer.InstallPackage( + packageId: TestPackageId, + versionRange: VersionRange.Parse(TestPackageVersion), + targetFramework: _testTargetframework, + additionalFeeds: new[] {emptySource}); + + AssertPackageInstall(reporter, fileSystem, package, store); + + package.Uninstall(); + } + [Theory] [InlineData(false)] [InlineData(true)] @@ -228,7 +252,31 @@ namespace Microsoft.DotNet.ToolPackage.Tests packageId: TestPackageId, versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, - source: source); + additionalFeeds: new[] {source}); + + AssertPackageInstall(reporter, fileSystem, package, store); + + package.Uninstall(); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public void GivenAEmptySourceAndNugetConfigInstallSucceeds(bool testMockBehaviorIsInSync) + { + var nugetConfigPath = WriteNugetConfigFileToPointToTheFeed(); + var emptySource = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + Directory.CreateDirectory(emptySource); + + var (store, installer, reporter, fileSystem) = Setup( + useMock: testMockBehaviorIsInSync, + feeds: GetMockFeedsForSource(emptySource)); + + var package = installer.InstallPackage( + packageId: TestPackageId, + versionRange: VersionRange.Parse(TestPackageVersion), + targetFramework: _testTargetframework, + nugetConfig: nugetConfigPath, additionalFeeds: new[] {emptySource}); AssertPackageInstall(reporter, fileSystem, package, store); @@ -281,7 +329,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests packageId: TestPackageId, versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, - source: source); + additionalFeeds: new[] {source}); FailedStepAfterSuccessRestore(); t.Complete(); @@ -313,7 +361,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests packageId: TestPackageId, versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, - source: source); + additionalFeeds: new[] {source}); first.ShouldNotThrow(); @@ -321,7 +369,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests packageId: TestPackageId, versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, - source: source); + additionalFeeds: new[] {source}); t.Complete(); } @@ -352,7 +400,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests packageId: TestPackageId, versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, - source: source); + additionalFeeds: new[] {source}); AssertPackageInstall(reporter, fileSystem, package, store); @@ -360,7 +408,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests packageId: TestPackageId, versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, - source: source); + additionalFeeds: new[] {source}); reporter.Lines.Should().BeEmpty(); @@ -401,7 +449,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests packageId: TestPackageId, versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, - source: source); + additionalFeeds: new[] {source}); AssertPackageInstall(reporter, fileSystem, package, store); @@ -425,7 +473,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests packageId: TestPackageId, versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, - source: source); + additionalFeeds: new[] {source}); AssertPackageInstall(reporter, fileSystem, package, store); @@ -458,7 +506,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests packageId: TestPackageId, versionRange: VersionRange.Parse(TestPackageVersion), targetFramework: _testTargetframework, - source: source); + additionalFeeds: new[] {source}); AssertPackageInstall(reporter, fileSystem, package, store); @@ -597,7 +645,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests { new MockFeed { - Type = MockFeedType.Source, + Type = MockFeedType.ImplicitAdditionalFeed, Uri = source, Packages = new List { @@ -617,7 +665,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests { new MockFeed { - Type = MockFeedType.OfflineFeed, + Type = MockFeedType.ImplicitAdditionalFeed, Uri = GetTestLocalFeedPath(), Packages = new List { diff --git a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/MockFeedType.cs b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/MockFeedType.cs index a6fd5c5c2..19ab3303d 100644 --- a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/MockFeedType.cs +++ b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/MockFeedType.cs @@ -7,7 +7,6 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks { FeedFromLookUpNugetConfig, ExplicitNugetConfig, - Source, - OfflineFeed + ImplicitAdditionalFeed } } diff --git a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ProjectRestorerMock.cs b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ProjectRestorerMock.cs index 7161dafb6..3e491140f 100644 --- a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ProjectRestorerMock.cs +++ b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ProjectRestorerMock.cs @@ -56,17 +56,14 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks } } - public void Restore( - FilePath project, + public void Restore(FilePath project, DirectoryPath assetJsonOutput, FilePath? nugetConfig = null, - string source = null, string verbosity = null) { string packageId; VersionRange versionRange; string targetFramework; - try { // The mock installer wrote a mock project file containing id:version:framework @@ -94,8 +91,7 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks var feedPackage = GetPackage( packageId, versionRange, - nugetConfig, - source); + nugetConfig); var packageVersion = feedPackage.Version; targetFramework = string.IsNullOrEmpty(targetFramework) ? "targetFramework" : targetFramework; @@ -118,49 +114,38 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks private MockFeedPackage GetPackage( string packageId, VersionRange versionRange = null, - FilePath? nugetConfig = null, - string source = null) + FilePath? nugetConfig = null) { - var allPackages = _feeds - .Where(f => { + var allPackages = _feeds + .Where(f => + { if (nugetConfig != null) { - return f.Type == MockFeedType.ExplicitNugetConfig && f.Uri == nugetConfig.Value.Value; - } - if (source != null) - { - return f.Type == MockFeedType.Source && f.Uri == source; + return ExcludeOtherFeeds(nugetConfig, f); } + return true; }) .SelectMany(f => f.Packages) .Where(f => f.PackageId == packageId); - var bestVersion = versionRange.FindBestMatch(allPackages.Select(p => NuGetVersion.Parse(p.Version))); + var bestVersion = versionRange.FindBestMatch(allPackages.Select(p => NuGetVersion.Parse(p.Version))); var package = allPackages.Where(p => NuGetVersion.Parse(p.Version).Equals(bestVersion)).FirstOrDefault(); if (package == null) { - if (_reporter != null) - { - _reporter.WriteLine($"Error: failed to restore package {packageId}."); - } + _reporter?.WriteLine($"Error: failed to restore package {packageId}."); throw new ToolPackageException(LocalizableStrings.ToolInstallationRestoreFailed); } return package; } - private static bool MatchPackage(MockFeedPackage p, string packageId, VersionRange versionRange) + private static bool ExcludeOtherFeeds(FilePath? nugetConfig, MockFeed f) { - if (string.Compare(p.PackageId, packageId, StringComparison.CurrentCultureIgnoreCase) != 0) - { - return false; - } - - return versionRange == null || - versionRange.FindBestMatch(new[] { NuGetVersion.Parse(p.Version) }) != null; + return f.Type == MockFeedType.ImplicitAdditionalFeed + || (f.Type == MockFeedType.ExplicitNugetConfig && f.Uri == nugetConfig.Value.Value); } } } diff --git a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageInstallerMock.cs b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageInstallerMock.cs index 2d058d6fb..539205cca 100644 --- a/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageInstallerMock.cs +++ b/test/Microsoft.DotNet.Tools.Tests.ComponentMocks/ToolPackageInstallerMock.cs @@ -35,13 +35,12 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks _installCallback = installCallback; } - public IToolPackage InstallPackage( - PackageId packageId, + public IToolPackage InstallPackage(PackageId packageId, VersionRange versionRange = null, string targetFramework = null, FilePath? nugetConfig = null, DirectoryPath? rootConfigDirectory = null, - string source = null, + string[] additionalFeeds = null, string verbosity = null) { var packageRootDirectory = _store.GetRootPackageDirectory(packageId); @@ -65,7 +64,6 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks tempProject, stageDirectory, nugetConfig, - source, verbosity); if (_installCallback != null) diff --git a/test/dotnet.Tests/CommandTests/InstallToolCommandTests.cs b/test/dotnet.Tests/CommandTests/InstallToolCommandTests.cs index a09ad4afa..923b34fa7 100644 --- a/test/dotnet.Tests/CommandTests/InstallToolCommandTests.cs +++ b/test/dotnet.Tests/CommandTests/InstallToolCommandTests.cs @@ -81,17 +81,17 @@ namespace Microsoft.DotNet.Tests.Commands public void WhenRunWithPackageIdWithSourceItShouldCreateValidShim() { const string sourcePath = "http://mysouce.com"; - ParseResult result = Parser.Instance.Parse($"dotnet install tool -g {PackageId} --source {sourcePath}"); + ParseResult result = Parser.Instance.Parse($"dotnet install tool -g {PackageId} --source-feed {sourcePath}"); AppliedOption appliedCommand = result["dotnet"]["install"]["tool"]; ParseResult parseResult = - Parser.Instance.ParseFrom("dotnet install", new[] { "tool", PackageId, "--source", sourcePath }); + Parser.Instance.ParseFrom("dotnet install", new[] { "tool", PackageId, "--source-feed", sourcePath }); var toolToolPackageInstaller = CreateToolPackageInstaller( feeds: new MockFeed[] { new MockFeed { - Type = MockFeedType.Source, + Type = MockFeedType.ImplicitAdditionalFeed, Uri = sourcePath, Packages = new List { diff --git a/test/dotnet.Tests/ParserTests/InstallToolParserTests.cs b/test/dotnet.Tests/ParserTests/InstallToolParserTests.cs index 191231821..7750d380b 100644 --- a/test/dotnet.Tests/ParserTests/InstallToolParserTests.cs +++ b/test/dotnet.Tests/ParserTests/InstallToolParserTests.cs @@ -54,10 +54,29 @@ namespace Microsoft.DotNet.Tests.ParserTests { const string expectedSourceValue = "TestSourceValue"; - var result = Parser.Instance.Parse($"dotnet install tool -g --source {expectedSourceValue} console.test.app"); + var result = + Parser.Instance.Parse($"dotnet install tool -g --source-feed {expectedSourceValue} console.test.app"); var appliedOptions = result["dotnet"]["install"]["tool"]; - appliedOptions.ValueOrDefault("source").Should().Be(expectedSourceValue); + appliedOptions.ValueOrDefault("source-feed").First().Should().Be(expectedSourceValue); + } + + [Fact] + public void InstallToolParserCanParseMultipleSourceOption() + { + const string expectedSourceValue1 = "TestSourceValue1"; + const string expectedSourceValue2 = "TestSourceValue2"; + + var result = + Parser.Instance.Parse( + $"dotnet install tool -g " + + $"--source-feed {expectedSourceValue1} " + + $"--source-feed {expectedSourceValue2} console.test.app"); + + var appliedOptions = result["dotnet"]["install"]["tool"]; + + appliedOptions.ValueOrDefault("source-feed")[0].Should().Be(expectedSourceValue1); + appliedOptions.ValueOrDefault("source-feed")[1].Should().Be(expectedSourceValue2); } [Fact] diff --git a/test/dotnet.Tests/ParserTests/UpdateToolParserTests.cs b/test/dotnet.Tests/ParserTests/UpdateToolParserTests.cs index ce870ff5c..b0c7b529e 100644 --- a/test/dotnet.Tests/ParserTests/UpdateToolParserTests.cs +++ b/test/dotnet.Tests/ParserTests/UpdateToolParserTests.cs @@ -62,10 +62,28 @@ namespace Microsoft.DotNet.Tests.ParserTests const string expectedSourceValue = "TestSourceValue"; var result = - Parser.Instance.Parse($"dotnet update tool -g --source {expectedSourceValue} console.test.app"); + Parser.Instance.Parse($"dotnet update tool -g --source-feed {expectedSourceValue} console.test.app"); var appliedOptions = result["dotnet"]["update"]["tool"]; - appliedOptions.ValueOrDefault("source").Should().Be(expectedSourceValue); + appliedOptions.ValueOrDefault("source-feed").First().Should().Be(expectedSourceValue); + } + + [Fact] + public void UpdateToolParserCanParseMultipleSourceOption() + { + const string expectedSourceValue1 = "TestSourceValue1"; + const string expectedSourceValue2 = "TestSourceValue2"; + + var result = + Parser.Instance.Parse( + $"dotnet update tool -g " + + $"--source-feed {expectedSourceValue1} " + + $"--source-feed {expectedSourceValue2} console.test.app"); + + var appliedOptions = result["dotnet"]["update"]["tool"]; + + appliedOptions.ValueOrDefault("source-feed")[0].Should().Be(expectedSourceValue1); + appliedOptions.ValueOrDefault("source-feed")[1].Should().Be(expectedSourceValue2); } [Fact]