Skip to content

Commit

Permalink
Use a nuget.config file instead of specifying multiple sources on the…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
0xced committed Mar 27, 2023
1 parent e71c549 commit 4828123
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/Serilog.Settings.Configuration.Tests/Support/TestApp.cs
Expand Up @@ -101,14 +101,13 @@ async Task PackAsync()

async Task RestoreAsync()
{
var packagesDirectory = _workingDirectory.SubDirectory("packages");
// 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.
// 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.
var restoreArgs = new[] {
"restore",
"--packages", packagesDirectory.FullName,
"--source", ".",
"--source", "https://api.nuget.org/v3/index.json",
"--configfile", "nuget.config",
"-p:Configuration=Release",
$"-p:TargetFramework={TargetFramework}"
$"-p:TargetFramework={TargetFramework}",
};
await RunDotnetAsync(_workingDirectory, restoreArgs);
}
Expand Down
11 changes: 11 additions & 0 deletions test/TestApp/nuget.config
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" value="packages" />
</config>
<packageSources>
<clear />
<add key="local" value="." />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

0 comments on commit 4828123

Please sign in to comment.