Skip to content

Commit 4828123

Browse files
committed
Use a nuget.config file instead of specifying multiple sources on the command line
This works around dotnet/sdk#27202 It also has the benefit of using settings _only_ from the specified config file, ignoring the global nuget.config where package source mapping could interfere with the local source.
1 parent e71c549 commit 4828123

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

test/Serilog.Settings.Configuration.Tests/Support/TestApp.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,13 @@ async Task PackAsync()
101101

102102
async Task RestoreAsync()
103103
{
104-
var packagesDirectory = _workingDirectory.SubDirectory("packages");
104+
// Can't use "--source . --source https://api.nuget.org/v3/index.json" because of https://github.com/dotnet/sdk/issues/27202 => a nuget.config file is used instead.
105+
// It also has the benefit of using settings _only_ from the specified config file, ignoring the global nuget.config where package source mapping could interfere with the local source.
105106
var restoreArgs = new[] {
106107
"restore",
107-
"--packages", packagesDirectory.FullName,
108-
"--source", ".",
109-
"--source", "https://api.nuget.org/v3/index.json",
108+
"--configfile", "nuget.config",
110109
"-p:Configuration=Release",
111-
$"-p:TargetFramework={TargetFramework}"
110+
$"-p:TargetFramework={TargetFramework}",
112111
};
113112
await RunDotnetAsync(_workingDirectory, restoreArgs);
114113
}

test/TestApp/nuget.config

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<config>
4+
<add key="globalPackagesFolder" value="packages" />
5+
</config>
6+
<packageSources>
7+
<clear />
8+
<add key="local" value="." />
9+
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
10+
</packageSources>
11+
</configuration>

0 commit comments

Comments
 (0)