Skip to content

Commit c14464d

Browse files
authored
Merge pull request #367 from microsoft/dev/andarno/fixAnalyzerTests
Fix analyzer tests to pull packages from our nuget.config feed
2 parents a64595b + cc79640 commit c14464d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
#pragma warning disable SA1202 // Elements should be ordered by access - because field initializer depend on each other
5+
46
using System.Collections.Immutable;
57
using Microsoft.CodeAnalysis.Testing;
68

79
internal static class ReferencesHelper
810
{
11+
private static readonly string NuGetConfigPath = FindNuGetConfigPath();
12+
913
public static readonly ReferenceAssemblies DefaultReferences = ReferenceAssemblies.Net.Net80
14+
.WithNuGetConfigFilePath(NuGetConfigPath)
1015
.WithPackages(ImmutableArray.Create(
1116
new PackageIdentity("System.ComponentModel.Composition", "8.0.0"),
1217
new PackageIdentity("System.Threading.Tasks.Extensions", "4.5.4"),
1318
new PackageIdentity("Microsoft.VisualStudio.Threading", "17.13.2"),
1419
new PackageIdentity("Microsoft.VisualStudio.Validation", "17.8.8")));
20+
21+
private static string FindNuGetConfigPath()
22+
{
23+
string? path = AppContext.BaseDirectory;
24+
while (path is not null)
25+
{
26+
string candidate = Path.Combine(path, "nuget.config");
27+
if (File.Exists(candidate))
28+
{
29+
return candidate;
30+
}
31+
32+
path = Path.GetDirectoryName(path);
33+
}
34+
35+
throw new InvalidOperationException("Could not find NuGet.config by searching up from " + AppContext.BaseDirectory);
36+
}
1537
}

0 commit comments

Comments
 (0)