Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/cli-test-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/dotnet/ToolPackage/IProjectRestorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
5 changes: 2 additions & 3 deletions src/dotnet/ToolPackage/IToolPackageInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
37 changes: 26 additions & 11 deletions src/dotnet/ToolPackage/ToolPackageInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ public ToolPackageInstaller(
_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);
Expand All @@ -55,16 +54,16 @@ public IToolPackage InstallPackage(
versionRange: versionRange,
targetFramework: targetFramework ?? BundledTargetFramework.GetTargetFrameworkMoniker(),
restoreDirectory: stageDirectory,
rootConfigDirectory: rootConfigDirectory);
rootConfigDirectory: rootConfigDirectory,
additionalFeeds: additionalFeeds);

try
{
_projectRestorer.Restore(
tempProject,
stageDirectory,
nugetConfig,
source,
verbosity);
verbosity: verbosity);
}
finally
{
Expand Down Expand Up @@ -113,12 +112,12 @@ public IToolPackage InstallPackage(
});
}

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())
Expand All @@ -141,8 +140,7 @@ private FilePath CreateTempProject(
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
Expand All @@ -157,5 +155,22 @@ private FilePath CreateTempProject(
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal class InstallToolCommand : CommandBase
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;
Expand All @@ -55,7 +55,7 @@ public InstallToolCommand(
_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");
Expand Down Expand Up @@ -137,7 +137,7 @@ public override int Execute()
versionRange: versionRange,
targetFramework: _framework,
nugetConfig: configFile,
source: _source,
additionalFeeds: _source,
verbosity: _verbosity);

foreach (var command in package.Commands)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public static Command InstallTool()
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ public ProjectRestorer(IReporter reporter = null)
_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>();
Expand All @@ -42,12 +40,6 @@ public void Restore(
argsToPassToRestore.Add(nugetConfig.Value.Value);
}

if (source != null)
{
argsToPassToRestore.Add("--source");
argsToPassToRestore.Add(source);
}

argsToPassToRestore.AddRange(new List<string>
{
"--runtime",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>You can invoke the tool using the following command: {0}
Tool '{1}' (version '{2}') was successfully installed.</source>
Expand Down Expand Up @@ -119,6 +109,16 @@ Nástroj {1} (verze {2}) byl úspěšně nainstalován.</target>
<target state="needs-review-translation">Umístění překrytí pro přístup k nástroji</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>
Original file line number Diff line number Diff line change
Expand Up @@ -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>You can invoke the tool using the following command: {0}
Tool '{1}' (version '{2}') was successfully installed.</source>
Expand Down Expand Up @@ -119,6 +109,16 @@ Das Tool "{1}" (Version "{2}") wurde erfolgreich installiert.</target>
<target state="needs-review-translation">Shim-Speicherort für Toolzugriff</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>
Original file line number Diff line number Diff line change
Expand Up @@ -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>You can invoke the tool using the following command: {0}
Tool '{1}' (version '{2}') was successfully installed.</source>
Expand Down Expand Up @@ -119,6 +109,16 @@ La herramienta "{1}" (versión "{2}") se instaló correctamente.</target>
<target state="needs-review-translation">Ubicación de las correcciones de compatibilidad (shim) para acceder a la herramienta</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>
Original file line number Diff line number Diff line change
Expand Up @@ -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>You can invoke the tool using the following command: {0}
Tool '{1}' (version '{2}') was successfully installed.</source>
Expand Down Expand Up @@ -119,6 +109,16 @@ L'outil '{1}' (version '{2}') a été installé.</target>
<target state="needs-review-translation">Emplacement de shim pour accéder à l'outil</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>
Original file line number Diff line number Diff line change
Expand Up @@ -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>You can invoke the tool using the following command: {0}
Tool '{1}' (version '{2}') was successfully installed.</source>
Expand Down Expand Up @@ -119,6 +109,16 @@ Lo strumento '{1}' (versione '{2}') è stato installato.</target>
<target state="needs-review-translation">Percorso dello shim per accedere allo strumento</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>
Loading