Change --source to --source-feed and make it additional ()

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
This commit is contained in:
William Lee 2018-03-19 22:22:45 -07:00 committed by GitHub
parent 67c4562f43
commit 9cc2b7cd2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 433 additions and 362 deletions

View file

@ -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

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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<string>();
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);
}
}
}

View file

@ -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<string>("version");
_configFilePath = appliedCommand.ValueOrDefault<string>("configfile");
_framework = appliedCommand.ValueOrDefault<string>("framework");
_source = appliedCommand.ValueOrDefault<string>("source");
_source = appliedCommand.ValueOrDefault<string[]>("source-feed");
_global = appliedCommand.ValueOrDefault<bool>("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)

View file

@ -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,

View file

@ -129,11 +129,11 @@
<data name="VersionOptionDescription" xml:space="preserve">
<value>Version of the tool package in NuGet.</value>
</data>
<data name="SourceOptionDescription" xml:space="preserve">
<value>Specifies a NuGet package source to use during installation.</value>
<data name="SourceFeedOptionDescription" xml:space="preserve">
<value>Adds an additional NuGet package source to use during installation.</value>
</data>
<data name="SourceOptionName" xml:space="preserve">
<value>SOURCE</value>
<data name="SourceFeedOptionName" xml:space="preserve">
<value>SOURCE_FEED</value>
</data>
<data name="CommandDescription" xml:space="preserve">
<value>Installs a tool for use on the command line.</value>

View file

@ -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<string>();
@ -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<string>
{
"--runtime",

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="cs" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">Určuje zdroj balíčku NuGet, který se použije při instalaci.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ Instalace byla úspěšná. Pokud nejsou další pokyny, můžete přímo do já
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="de" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">Gibt eine NuGet-Paketquelle für die Installation an.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ Die Installation war erfolgreich. Sofern keine weiteren Anweisungen vorliegen, k
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="es" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">Especifica el origen de un paquete NuGet para usarlo durante la instalación.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">ORIGEN</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ La instalación se completó correctamente. Si no hay más instrucciones, puede
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="fr" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">Spécifie un package NuGet source à utiliser durant l'installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ L'installation a réussi. En l'absence d'instructions supplémentaires, vous pou
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="it" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">Consente di specificare un'origine pacchetto NuGet da usare durante l'installazione.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">ORIGINE</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ L'installazione è riuscita. Se non ci sono altre istruzioni, è possibile digit
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ja" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">インストール中に使用する NuGet パッケージを指定します。</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed.</source>
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ko" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">설치 중 사용할 NuGet 패키지 소스를 지정합니다.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed.</source>
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pl" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">Określa źródło pakietu NuGet do użycia podczas instalacji.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">ŹRÓDŁO</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ Instalacja powiodła się. Jeśli nie ma dodatkowych instrukcji, możesz wpisać
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pt-BR" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">Especifica uma origem do pacote NuGet a ser usada durante a instalação.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">ORIGEM</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ A instalação foi bem-sucedida. Se não houver outras instruções, digite o se
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ru" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">Задает источник пакета NuGet, используемый во время установки.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed.</source>
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="tr" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">Yükleme sırasında kullanılacak bir NuGet paket kaynağı belirtir.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ Yükleme başarılı oldu. Daha fazla yönerge yoksa, çağırmak için şu komu
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="zh-Hans" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">指定安装期间使用的 NuGet 包源。</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed.</source>
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -2,16 +2,6 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="zh-Hant" original="../LocalizableStrings.resx">
<body>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during installation.</source>
<target state="translated">指定於安裝期間要使用的 NuGet 套件來源。</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="InstallationSucceeded">
<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.</source>
@ -119,6 +109,16 @@ Tool '{1}' (version '{2}') was successfully installed.</source>
<target state="new">Location of shim to access tool</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during installation.</source>
<target state="new">Adds an additional NuGet package source to use during installation.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -129,11 +129,11 @@
<data name="VersionOptionDescription" xml:space="preserve">
<value>Version of the tool package in NuGet.</value>
</data>
<data name="SourceOptionDescription" xml:space="preserve">
<value>Specifies a NuGet package source to use during update.</value>
<data name="SourceFeedOptionDescription" xml:space="preserve">
<value>Adds an additional NuGet package source to use during update.</value>
</data>
<data name="SourceOptionName" xml:space="preserve">
<value>SOURCE</value>
<data name="SourceFeedOptionName" xml:space="preserve">
<value>SOURCE_FEED</value>
</data>
<data name="CommandDescription" xml:space="preserve">
<value>Updates a tool to the latest stable version for use.</value>

View file

@ -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<string>("configfile");
_framework = appliedCommand.ValueOrDefault<string>("framework");
_source = appliedCommand.ValueOrDefault<string>("source");
_additionalFeeds = appliedCommand.ValueOrDefault<string[]>("source-feed");
_global = appliedCommand.ValueOrDefault<bool>("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)

View file

@ -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,

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -22,16 +22,6 @@
<target state="new">Version of the tool package in NuGet.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionDescription">
<source>Specifies a NuGet package source to use during update.</source>
<target state="new">Specifies a NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceOptionName">
<source>SOURCE</source>
<target state="new">SOURCE</target>
<note />
</trans-unit>
<trans-unit id="CommandDescription">
<source>Updates a tool to the latest stable version for use.</source>
<target state="new">Updates a tool to the latest stable version for use.</target>
@ -102,6 +92,16 @@
<target state="new">Tool '{0}' failed to update due to the following:</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionDescription">
<source>Adds an additional NuGet package source to use during update.</source>
<target state="new">Adds an additional NuGet package source to use during update.</target>
<note />
</trans-unit>
<trans-unit id="SourceFeedOptionName">
<source>SOURCE_FEED</source>
<target state="new">SOURCE_FEED</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -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<MockFeedPackage>
{
@ -617,7 +665,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests
{
new MockFeed
{
Type = MockFeedType.OfflineFeed,
Type = MockFeedType.ImplicitAdditionalFeed,
Uri = GetTestLocalFeedPath(),
Packages = new List<MockFeedPackage>
{

View file

@ -7,7 +7,6 @@ namespace Microsoft.DotNet.Tools.Tests.ComponentMocks
{
FeedFromLookUpNugetConfig,
ExplicitNugetConfig,
Source,
OfflineFeed
ImplicitAdditionalFeed
}
}

View file

@ -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);
}
}
}

View file

@ -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)

View file

@ -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<MockFeedPackage>
{

View file

@ -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<string>("source").Should().Be(expectedSourceValue);
appliedOptions.ValueOrDefault<string[]>("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<string[]>("source-feed")[0].Should().Be(expectedSourceValue1);
appliedOptions.ValueOrDefault<string[]>("source-feed")[1].Should().Be(expectedSourceValue2);
}
[Fact]

View file

@ -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<string>("source").Should().Be(expectedSourceValue);
appliedOptions.ValueOrDefault<string[]>("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<string[]>("source-feed")[0].Should().Be(expectedSourceValue1);
appliedOptions.ValueOrDefault<string[]>("source-feed")[1].Should().Be(expectedSourceValue2);
}
[Fact]