Skip to content

Commit 87c80db

Browse files
committed
Update StyleCopTester to the new Microsoft.CodeAnalysis.Workspaces.MSBuild
1 parent c729eef commit 87c80db

5 files changed

Lines changed: 23 additions & 23 deletions

File tree

NuGet.config

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

StyleCop.Analyzers/StyleCopTester/App.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

StyleCop.Analyzers/StyleCopTester/Program.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace StyleCopTester
1515
using System.Threading;
1616
using System.Threading.Tasks;
1717
using System.Windows.Threading;
18+
using Microsoft.Build.Locator;
1819
using Microsoft.CodeAnalysis;
1920
using Microsoft.CodeAnalysis.CodeActions;
2021
using Microsoft.CodeAnalysis.CodeFixes;
@@ -85,6 +86,8 @@ private static async Task MainAsync(string[] args, CancellationToken cancellatio
8586
}
8687
}
8788

89+
MSBuildLocator.RegisterDefaults();
90+
8891
Stopwatch stopwatch = Stopwatch.StartNew();
8992
var analyzers = GetAllAnalyzers();
9093

@@ -96,9 +99,17 @@ private static async Task MainAsync(string[] args, CancellationToken cancellatio
9699
return;
97100
}
98101

102+
var properties = new Dictionary<string, string>
103+
{
104+
// This property ensures that XAML files will be compiled in the current AppDomain
105+
// rather than a separate one. Any tasks isolated in AppDomains or tasks that create
106+
// AppDomains will likely not work due to https://github.com/Microsoft/MSBuildLocator/issues/16.
107+
{ "AlwaysCompileMarkupFilesInSeparateDomain", bool.FalseString },
108+
};
109+
99110
MSBuildWorkspace workspace = MSBuildWorkspace.Create();
100111
string solutionPath = args.SingleOrDefault(i => !i.StartsWith("/", StringComparison.Ordinal));
101-
Solution solution = await workspace.OpenSolutionAsync(solutionPath, cancellationToken).ConfigureAwait(false);
112+
Solution solution = await workspace.OpenSolutionAsync(solutionPath, cancellationToken: cancellationToken).ConfigureAwait(false);
102113

103114
Console.WriteLine($"Loaded solution in {stopwatch.ElapsedMilliseconds}ms");
104115

StyleCop.Analyzers/StyleCopTester/Properties/launchSettings.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,13 @@
55
"commandLineArgs": "..\\..\\StyleCopAnalyzers.sln /stats",
66
"workingDirectory": "$(MSBuildProjectDirectory)",
77
"environmentVariables": {
8-
"MSBuildSDKsPath": "$(MSBuildSDKsPath)",
9-
"MSBuildExtensionsPath": "$(MSBuildExtensionsPath)",
10-
"VisualStudioVersion": "$(VisualStudioVersion)",
11-
"VSINSTALLDIR": "$(VSAPPIDDIR)\\..\\..\\"
128
}
139
},
1410
"StyleCopAnalyzers.sln /stats /editperf": {
1511
"commandName": "Project",
1612
"commandLineArgs": "..\\..\\StyleCopAnalyzers.sln /stats /editperf",
1713
"workingDirectory": "$(MSBuildProjectDirectory)",
1814
"environmentVariables": {
19-
"MSBuildSDKsPath": "$(MSBuildSDKsPath)",
20-
"MSBuildExtensionsPath": "$(MSBuildExtensionsPath)",
21-
"VisualStudioVersion": "$(VisualStudioVersion)",
22-
"VSINSTALLDIR": "$(VSAPPIDDIR)\\..\\..\\"
2315
}
2416
}
2517
}

StyleCop.Analyzers/StyleCopTester/StyleCopTester.csproj

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,16 @@
2323
</ItemGroup>
2424

2525
<ItemGroup>
26-
<PackageReference Include="Microsoft.Build" Version="15.3.409" />
27-
<PackageReference Include="Microsoft.Build.Framework" Version="15.3.409" />
28-
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.3.409" />
29-
<PackageReference Include="Microsoft.CodeAnalysis" Version="1.2.1" />
26+
<PackageReference Include="Microsoft.Build.Locator" Version="1.0.13" />
27+
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version=" 2.9.0-beta4-62830-01" />
28+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version=" 2.9.0-beta4-62830-01" />
29+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version=" 2.9.0-beta4-62830-01" />
30+
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version=" 2.9.0-beta4-62830-01" />
3031
</ItemGroup>
3132

3233
<ItemGroup>
3334
<ProjectReference Include="..\StyleCop.Analyzers.CodeFixes\StyleCop.Analyzers.CodeFixes.csproj" />
3435
<ProjectReference Include="..\StyleCop.Analyzers\StyleCop.Analyzers.csproj" />
3536
</ItemGroup>
3637

37-
<ItemGroup>
38-
<None Include="App.config" />
39-
</ItemGroup>
40-
4138
</Project>

0 commit comments

Comments
 (0)