Skip to content

Commit 6711c1b

Browse files
committed
remove RestoreSources from project file
1 parent 0ef619f commit 6711c1b

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

test/coverlet.integration.determisticbuild/coverlet.integration.determisticbuild.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
<AssemblyName>coverletsample.integration.determisticbuild</AssemblyName>
99
<MSBuildWarningsAsMessages>NU1604</MSBuildWarningsAsMessages>
1010
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
11-
<RestoreSources>
12-
https://api.nuget.org/v3/index.json;
13-
$(RepoRoot)artifacts/package/$(Configuration.ToLowerInvariant())
14-
</RestoreSources>
1511
</PropertyGroup>
1612

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

test/coverlet.integration.tests/BaseTest.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,12 @@ private protected void UpdateNugetConfigWithLocalPackageFolder(string projectPat
124124

125125
string localPackageFolder = TestUtils.GetPackagePath(TestUtils.GetAssemblyBuildConfiguration().ToString().ToLowerInvariant());
126126

127-
xml.Element("configuration")!
128-
.Element("packageSources")!
129-
.Elements()
130-
.ElementAt(0)
131-
.AddAfterSelf(new XElement("add", new XAttribute("key", "localCoverletPackages"), new XAttribute("value", localPackageFolder)));
127+
var packageSourcesElement = xml.Element("configuration")?.Element("packageSources");
128+
if (packageSourcesElement != null && !packageSourcesElement.Elements().Any(e => e.Attribute("key")?.Value == "localCoverletPackages"))
129+
{
130+
packageSourcesElement.Add(new XElement("add", new XAttribute("key", "localCoverletPackages"), new XAttribute("value", localPackageFolder)));
131+
}
132+
132133
xml.Save(nugetFile);
133134
}
134135

test/coverlet.integration.tests/DeterministicBuild.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public void Msbuild()
9191
string testResultPath = Path.Join(_testResultsPath, ((ITest)_testMember!.GetValue(_output)!).DisplayName);
9292
string logFilename = string.Concat(((ITest)_testMember!.GetValue(_output)!).DisplayName, ".binlog");
9393
CreateDeterministicTestPropsFile();
94+
UpdateNugetConfigWithLocalPackageFolder(_testProjectPath);
9495

9596
DotnetCli($"build -c {_buildConfiguration} -bl:build.{logFilename} /p:DeterministicSourcePaths=true", out string standardOutput, out string standardError, _testProjectPath);
9697
if (!string.IsNullOrEmpty(standardError))
@@ -134,6 +135,7 @@ public void Msbuild_SourceLink()
134135
string testResultPath = Path.Join(_testResultsPath, ((ITest)_testMember!.GetValue(_output)!).DisplayName);
135136
string logFilename = string.Concat(((ITest)_testMember!.GetValue(_output)!).DisplayName, ".binlog");
136137
CreateDeterministicTestPropsFile();
138+
UpdateNugetConfigWithLocalPackageFolder(_testProjectPath);
137139

138140
DotnetCli($"build -c {_buildConfiguration} -bl:build.{logFilename} --verbosity normal /p:DeterministicSourcePaths=true", out string standardOutput, out string standardError, _testProjectPath);
139141
if (!string.IsNullOrEmpty(standardError))
@@ -181,6 +183,7 @@ public void Collectors()
181183
string logFilename = string.Concat(((ITest)_testMember!.GetValue(_output)!).DisplayName, ".binlog");
182184

183185
CreateDeterministicTestPropsFile();
186+
UpdateNugetConfigWithLocalPackageFolder(_testProjectPath);
184187
DeleteLogFiles(testLogFilesPath);
185188
DeleteCoverageFiles(testResultPath);
186189

@@ -236,6 +239,7 @@ public void Collectors_SourceLink()
236239
string logFilename = string.Concat(((ITest)_testMember!.GetValue(_output)!).DisplayName, ".binlog");
237240

238241
CreateDeterministicTestPropsFile();
242+
UpdateNugetConfigWithLocalPackageFolder(_testProjectPath);
239243
DeleteLogFiles(testLogFilesPath);
240244
DeleteCoverageFiles(testResultPath);
241245

0 commit comments

Comments
 (0)