Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 9cc2b7c

Browse files
author
William Lee
authored
Change --source to --source-feed and make it additional (#8833)
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 microsoft/dotnet#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
1 parent 67c4562 commit 9cc2b7c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+433
-362
lines changed

scripts/cli-test-env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ REPO_ROOT="$( cd -P "$( dirname "$SOURCE" )/../" && pwd )"
1616
uname=$(uname)
1717
if [ "$(uname)" = "Darwin" ]
1818
then
19-
RID=osx.10.13-x64
19+
RID=osx-x64
2020
else
2121
RID=linux-x64
2222
fi

src/dotnet/ToolPackage/IProjectRestorer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ namespace Microsoft.DotNet.ToolPackage
88
{
99
internal interface IProjectRestorer
1010
{
11-
void Restore(
12-
FilePath project,
11+
void Restore(FilePath project,
1312
DirectoryPath assetJsonOutput,
1413
FilePath? nugetConfig = null,
15-
string source = null,
1614
string verbosity = null);
1715
}
1816
}

src/dotnet/ToolPackage/IToolPackageInstaller.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ namespace Microsoft.DotNet.ToolPackage
1010
{
1111
internal interface IToolPackageInstaller
1212
{
13-
IToolPackage InstallPackage(
14-
PackageId packageId,
13+
IToolPackage InstallPackage(PackageId packageId,
1514
VersionRange versionRange = null,
1615
string targetFramework = null,
1716
FilePath? nugetConfig = null,
1817
DirectoryPath? rootConfigDirectory = null,
19-
string source = null,
18+
string[] additionalFeeds = null,
2019
string verbosity = null);
2120
}
2221
}

src/dotnet/ToolPackage/ToolPackageInstaller.cs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ public ToolPackageInstaller(
3030
_offlineFeed = offlineFeed ?? new DirectoryPath(new CliFolderPathCalculator().CliFallbackFolderPath);
3131
}
3232

33-
public IToolPackage InstallPackage(
34-
PackageId packageId,
33+
public IToolPackage InstallPackage(PackageId packageId,
3534
VersionRange versionRange = null,
3635
string targetFramework = null,
3736
FilePath? nugetConfig = null,
3837
DirectoryPath? rootConfigDirectory = null,
39-
string source = null,
38+
string[] additionalFeeds = null,
4039
string verbosity = null)
4140
{
4241
var packageRootDirectory = _store.GetRootPackageDirectory(packageId);
@@ -55,16 +54,16 @@ public IToolPackage InstallPackage(
5554
versionRange: versionRange,
5655
targetFramework: targetFramework ?? BundledTargetFramework.GetTargetFrameworkMoniker(),
5756
restoreDirectory: stageDirectory,
58-
rootConfigDirectory: rootConfigDirectory);
57+
rootConfigDirectory: rootConfigDirectory,
58+
additionalFeeds: additionalFeeds);
5959

6060
try
6161
{
6262
_projectRestorer.Restore(
6363
tempProject,
6464
stageDirectory,
6565
nugetConfig,
66-
source,
67-
verbosity);
66+
verbosity: verbosity);
6867
}
6968
finally
7069
{
@@ -113,12 +112,12 @@ public IToolPackage InstallPackage(
113112
});
114113
}
115114

116-
private FilePath CreateTempProject(
117-
PackageId packageId,
115+
private FilePath CreateTempProject(PackageId packageId,
118116
VersionRange versionRange,
119117
string targetFramework,
120118
DirectoryPath restoreDirectory,
121-
DirectoryPath? rootConfigDirectory)
119+
DirectoryPath? rootConfigDirectory,
120+
string[] additionalFeeds)
122121
{
123122
var tempProject = _tempProject ?? new DirectoryPath(Path.GetTempPath())
124123
.WithSubDirectories(Path.GetRandomFileName())
@@ -141,8 +140,7 @@ private FilePath CreateTempProject(
141140
new XElement("RestoreRootConfigDirectory", rootConfigDirectory?.Value ?? Directory.GetCurrentDirectory()), // config file probing start directory
142141
new XElement("DisableImplicitFrameworkReferences", "true"), // no Microsoft.NETCore.App in tool folder
143142
new XElement("RestoreFallbackFolders", "clear"), // do not use fallbackfolder, tool package need to be copied to tool folder
144-
new XElement("RestoreAdditionalProjectSources", // use fallbackfolder as feed to enable offline
145-
Directory.Exists(_offlineFeed.Value) ? _offlineFeed.Value : string.Empty),
143+
new XElement("RestoreAdditionalProjectSources", JoinSourceAndOfflineCache(additionalFeeds)),
146144
new XElement("RestoreAdditionalProjectFallbackFolders", string.Empty), // block other
147145
new XElement("RestoreAdditionalProjectFallbackFoldersExcludes", string.Empty), // block other
148146
new XElement("DisableImplicitNuGetFallbackFolder", "true")), // disable SDK side implicit NuGetFallbackFolder
@@ -157,5 +155,22 @@ private FilePath CreateTempProject(
157155
File.WriteAllText(tempProject.Value, tempProjectContent.ToString());
158156
return tempProject;
159157
}
158+
159+
private string JoinSourceAndOfflineCache(string[] additionalFeeds)
160+
{
161+
var feeds = new List<string>();
162+
if (additionalFeeds != null)
163+
{
164+
feeds.AddRange(additionalFeeds);
165+
}
166+
167+
// use fallbackfolder as feed to enable offline
168+
if (Directory.Exists(_offlineFeed.Value))
169+
{
170+
feeds.Add(_offlineFeed.ToXmlEncodeString());
171+
}
172+
173+
return string.Join(";", feeds);
174+
}
160175
}
161176
}

src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal class InstallToolCommand : CommandBase
3232
private readonly string _packageVersion;
3333
private readonly string _configFilePath;
3434
private readonly string _framework;
35-
private readonly string _source;
35+
private readonly string[] _source;
3636
private readonly bool _global;
3737
private readonly string _verbosity;
3838
private readonly string _toolPath;
@@ -55,7 +55,7 @@ public InstallToolCommand(
5555
_packageVersion = appliedCommand.ValueOrDefault<string>("version");
5656
_configFilePath = appliedCommand.ValueOrDefault<string>("configfile");
5757
_framework = appliedCommand.ValueOrDefault<string>("framework");
58-
_source = appliedCommand.ValueOrDefault<string>("source");
58+
_source = appliedCommand.ValueOrDefault<string[]>("source-feed");
5959
_global = appliedCommand.ValueOrDefault<bool>("global");
6060
_verbosity = appliedCommand.SingleArgumentOrDefault("verbosity");
6161
_toolPath = appliedCommand.SingleArgumentOrDefault("tool-path");
@@ -137,7 +137,7 @@ public override int Execute()
137137
versionRange: versionRange,
138138
targetFramework: _framework,
139139
nugetConfig: configFile,
140-
source: _source,
140+
additionalFeeds: _source,
141141
verbosity: _verbosity);
142142

143143
foreach (var command in package.Commands)

src/dotnet/commands/dotnet-install/dotnet-install-tool/InstallToolCommandParser.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ public static Command InstallTool()
3232
LocalizableStrings.ConfigFileOptionDescription,
3333
Accept.ExactlyOneArgument()),
3434
Create.Option(
35-
"--source",
36-
LocalizableStrings.SourceOptionDescription,
37-
Accept.ExactlyOneArgument()
38-
.With(name: LocalizableStrings.SourceOptionName)),
35+
"--source-feed",
36+
LocalizableStrings.SourceFeedOptionDescription,
37+
Accept.OneOrMoreArguments()
38+
.With(name: LocalizableStrings.SourceFeedOptionName)),
3939
Create.Option(
4040
"-f|--framework",
4141
LocalizableStrings.FrameworkOptionDescription,

src/dotnet/commands/dotnet-install/dotnet-install-tool/LocalizableStrings.resx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@
129129
<data name="VersionOptionDescription" xml:space="preserve">
130130
<value>Version of the tool package in NuGet.</value>
131131
</data>
132-
<data name="SourceOptionDescription" xml:space="preserve">
133-
<value>Specifies a NuGet package source to use during installation.</value>
132+
<data name="SourceFeedOptionDescription" xml:space="preserve">
133+
<value>Adds an additional NuGet package source to use during installation.</value>
134134
</data>
135-
<data name="SourceOptionName" xml:space="preserve">
136-
<value>SOURCE</value>
135+
<data name="SourceFeedOptionName" xml:space="preserve">
136+
<value>SOURCE_FEED</value>
137137
</data>
138138
<data name="CommandDescription" xml:space="preserve">
139139
<value>Installs a tool for use on the command line.</value>

src/dotnet/commands/dotnet-install/dotnet-install-tool/ProjectRestorer.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ public ProjectRestorer(IReporter reporter = null)
2626
_forceOutputRedirection = reporter != null;
2727
}
2828

29-
public void Restore(
30-
FilePath project,
29+
public void Restore(FilePath project,
3130
DirectoryPath assetJsonOutput,
3231
FilePath? nugetConfig = null,
33-
string source = null,
3432
string verbosity = null)
3533
{
3634
var argsToPassToRestore = new List<string>();
@@ -42,12 +40,6 @@ public void Restore(
4240
argsToPassToRestore.Add(nugetConfig.Value.Value);
4341
}
4442

45-
if (source != null)
46-
{
47-
argsToPassToRestore.Add("--source");
48-
argsToPassToRestore.Add(source);
49-
}
50-
5143
argsToPassToRestore.AddRange(new List<string>
5244
{
5345
"--runtime",

src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.cs.xlf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22
<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">
33
<file datatype="xml" source-language="en" target-language="cs" original="../LocalizableStrings.resx">
44
<body>
5-
<trans-unit id="SourceOptionDescription">
6-
<source>Specifies a NuGet package source to use during installation.</source>
7-
<target state="translated">Určuje zdroj balíčku NuGet, který se použije při instalaci.</target>
8-
<note />
9-
</trans-unit>
10-
<trans-unit id="SourceOptionName">
11-
<source>SOURCE</source>
12-
<target state="translated">SOURCE</target>
13-
<note />
14-
</trans-unit>
155
<trans-unit id="InstallationSucceeded">
166
<source>If there were no additional instructions, you can type the following command to invoke the tool: {0}
177
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á
119109
<target state="new">Location of shim to access tool</target>
120110
<note />
121111
</trans-unit>
112+
<trans-unit id="SourceFeedOptionDescription">
113+
<source>Adds an additional NuGet package source to use during installation.</source>
114+
<target state="new">Adds an additional NuGet package source to use during installation.</target>
115+
<note />
116+
</trans-unit>
117+
<trans-unit id="SourceFeedOptionName">
118+
<source>SOURCE_FEED</source>
119+
<target state="new">SOURCE_FEED</target>
120+
<note />
121+
</trans-unit>
122122
</body>
123123
</file>
124124
</xliff>

src/dotnet/commands/dotnet-install/dotnet-install-tool/xlf/LocalizableStrings.de.xlf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22
<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">
33
<file datatype="xml" source-language="en" target-language="de" original="../LocalizableStrings.resx">
44
<body>
5-
<trans-unit id="SourceOptionDescription">
6-
<source>Specifies a NuGet package source to use during installation.</source>
7-
<target state="translated">Gibt eine NuGet-Paketquelle für die Installation an.</target>
8-
<note />
9-
</trans-unit>
10-
<trans-unit id="SourceOptionName">
11-
<source>SOURCE</source>
12-
<target state="translated">SOURCE</target>
13-
<note />
14-
</trans-unit>
155
<trans-unit id="InstallationSucceeded">
166
<source>If there were no additional instructions, you can type the following command to invoke the tool: {0}
177
Tool '{1}' (version '{2}') was successfully installed.</source>
@@ -119,6 +109,16 @@ Die Installation war erfolgreich. Sofern keine weiteren Anweisungen vorliegen, k
119109
<target state="new">Location of shim to access tool</target>
120110
<note />
121111
</trans-unit>
112+
<trans-unit id="SourceFeedOptionDescription">
113+
<source>Adds an additional NuGet package source to use during installation.</source>
114+
<target state="new">Adds an additional NuGet package source to use during installation.</target>
115+
<note />
116+
</trans-unit>
117+
<trans-unit id="SourceFeedOptionName">
118+
<source>SOURCE_FEED</source>
119+
<target state="new">SOURCE_FEED</target>
120+
<note />
121+
</trans-unit>
122122
</body>
123123
</file>
124124
</xliff>

0 commit comments

Comments
 (0)