From 9cc2b7cd2f9dc165ee3a04b1de6fa5065b142dd3 Mon Sep 17 00:00:00 2001 From: William Lee Date: Mon, 19 Mar 2018 22:22:45 -0700 Subject: [PATCH] Change --source to --source-feed and make it additional (#8833) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Other than change source to source-feed and make it additional instead of exclusive. I changed source to be multiple. Because restore support multiple source https://github.com/Microsoft/dotnet/issues/361 As for mock. The offline feed and source feed is considered the same, so remove the category of “source”. I renamed source to “AdditionalFeed” because that is more accurate on implementation level. Note: NuGet feed don’t have order. Whichever responses the fastest, is the first. No change on restore. scripts/cli-test-env.sh change is due to mac 10.13 is finally added to RID graph. And it is “considered” one of the CLI supported RID --- scripts/cli-test-env.sh | 2 +- src/dotnet/ToolPackage/IProjectRestorer.cs | 4 +- .../ToolPackage/IToolPackageInstaller.cs | 5 +- .../ToolPackage/ToolPackageInstaller.cs | 37 +++++++--- .../dotnet-install-tool/InstallToolCommand.cs | 6 +- .../InstallToolCommandParser.cs | 8 +-- .../LocalizableStrings.resx | 8 +-- .../dotnet-install-tool/ProjectRestorer.cs | 10 +-- .../xlf/LocalizableStrings.cs.xlf | 20 +++--- .../xlf/LocalizableStrings.de.xlf | 20 +++--- .../xlf/LocalizableStrings.es.xlf | 20 +++--- .../xlf/LocalizableStrings.fr.xlf | 20 +++--- .../xlf/LocalizableStrings.it.xlf | 20 +++--- .../xlf/LocalizableStrings.ja.xlf | 20 +++--- .../xlf/LocalizableStrings.ko.xlf | 20 +++--- .../xlf/LocalizableStrings.pl.xlf | 20 +++--- .../xlf/LocalizableStrings.pt-BR.xlf | 20 +++--- .../xlf/LocalizableStrings.ru.xlf | 20 +++--- .../xlf/LocalizableStrings.tr.xlf | 20 +++--- .../xlf/LocalizableStrings.zh-Hans.xlf | 20 +++--- .../xlf/LocalizableStrings.zh-Hant.xlf | 20 +++--- .../tool/LocalizableStrings.resx | 8 +-- .../dotnet-update/tool/UpdateToolCommand.cs | 6 +- .../tool/UpdateToolCommandParser.cs | 8 +-- .../tool/xlf/LocalizableStrings.cs.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.de.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.es.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.fr.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.it.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.ja.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.ko.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.pl.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.pt-BR.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.ru.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.tr.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.zh-Hans.xlf | 20 +++--- .../tool/xlf/LocalizableStrings.zh-Hant.xlf | 20 +++--- .../ToolPackageInstallerTests.cs | 72 +++++++++++++++---- .../MockFeedType.cs | 3 +- .../ProjectRestorerMock.cs | 41 ++++------- .../ToolPackageInstallerMock.cs | 6 +- .../CommandTests/InstallToolCommandTests.cs | 6 +- .../ParserTests/InstallToolParserTests.cs | 23 +++++- .../ParserTests/UpdateToolParserTests.cs | 22 +++++- 44 files changed, 433 insertions(+), 362 deletions(-) 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 a6f6cc58c..d74dda56e 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 bb04e2bfb..035aa553e 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Instalace byla úspěšná. Pokud nejsou další pokyny, můžete přímo do já Location of shim to access tool + + 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 e97c39e5d..5830c4aa3 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Die Installation war erfolgreich. Sofern keine weiteren Anweisungen vorliegen, k Location of shim to access tool + + 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 c5e4465b6..d4c2b4d8a 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ La instalación se completó correctamente. Si no hay más instrucciones, puede Location of shim to access tool + + 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 e9e97f243..067258b75 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ L'installation a réussi. En l'absence d'instructions supplémentaires, vous pou Location of shim to access tool + + 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 578339d9a..70816d492 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ L'installazione è riuscita. Se non ci sono altre istruzioni, è possibile digit Location of shim to access tool + + 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 cd32d2d52..8aec5915e 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed. Location of shim to access tool + + 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 3f5c31436..18a1f09a8 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed. Location of shim to access tool + + 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 33fbb68c4..d8dcac491 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Instalacja powiodła się. Jeśli nie ma dodatkowych instrukcji, możesz wpisać Location of shim to access tool + + 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 3de8ddbc3..def0a0021 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ A instalação foi bem-sucedida. Se não houver outras instruções, digite o se Location of shim to access tool + + 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 2d167c9e2..2365e75c2 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed. Location of shim to access tool + + 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 de1fd3e5f..481e356cf 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Yükleme başarılı oldu. Daha fazla yönerge yoksa, çağırmak için şu komu Location of shim to access tool + + 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 98c614b43..b522b0202 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed. Location of shim to access tool + + 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 82e923141..299606dff 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 - - If there were no additional instructions, you can type the following command to invoke the tool: {0} Tool '{1}' (version '{2}') was successfully installed. @@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed. Location of shim to access tool + + 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 b487c7dfb..b8def9296 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 1c9b54e64..305400ef7 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]