Skip to content

Commit 005e0a2

Browse files
committed
Fix analyzer tests to pull packages from our nuget.config feed
This fixes a Azure Pipeline break in the devdiv projedct where network isolation is enabled.
1 parent be47b98 commit 005e0a2

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,10 +1,32 @@
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
internal static class ReferencesHelper
57
{
8+
private static readonly string NuGetConfigPath = FindNuGetConfigPath();
9+
610
internal static ReferenceAssemblies DefaultReferences = ReferenceAssemblies.NetFramework.Net472.Default
11+
.WithNuGetConfigFilePath(NuGetConfigPath)
712
.WithPackages(ImmutableArray.Create(
813
new PackageIdentity("System.Composition.AttributedModel", "6.0.0"),
914
new PackageIdentity("System.ComponentModel.Composition", "6.0.0")));
15+
16+
private static string FindNuGetConfigPath()
17+
{
18+
string? path = AppContext.BaseDirectory;
19+
while (path is not null)
20+
{
21+
string candidate = Path.Combine(path, "nuget.config");
22+
if (File.Exists(candidate))
23+
{
24+
return candidate;
25+
}
26+
27+
path = Path.GetDirectoryName(path);
28+
}
29+
30+
throw new InvalidOperationException("Could not find NuGet.config by searching up from " + AppContext.BaseDirectory);
31+
}
1032
}

0 commit comments

Comments
 (0)