Skip to content

Commit 0102ef6

Browse files
committed
Update to the latest MSBuildWorkspace prerelease that supports CPS projects
1 parent 9fc213b commit 0102ef6

6 files changed

Lines changed: 36 additions & 9 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="roslyn" value="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
5+
</packageSources>
6+
</configuration>
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
5-
</startup>
3+
<runtime>
4+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5+
<dependentAssembly>
6+
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
7+
<bindingRedirect oldVersion="0.0.0.0-2.9.0.0" newVersion="2.9.0.0" />
8+
</dependentAssembly>
9+
</assemblyBinding>
10+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
11+
<dependentAssembly>
12+
<assemblyIdentity name="Microsoft.CodeAnalysis.Workspaces" publicKeyToken="31bf3856ad364e35" culture="neutral" />
13+
<bindingRedirect oldVersion="0.0.0.0-2.9.0.0" newVersion="2.9.0.0" />
14+
</dependentAssembly>
15+
</assemblyBinding>
16+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
17+
<dependentAssembly>
18+
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral" />
19+
<bindingRedirect oldVersion="0.0.0.0-2.9.0.0" newVersion="2.9.0.0" />
20+
</dependentAssembly>
21+
</assemblyBinding>
22+
</runtime>
623
</configuration>

StyleCop.Analyzers.Status.Generator/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace StyleCop.Analyzers.Status.Generator
77
using System.IO;
88
using System.Linq;
99
using LibGit2Sharp;
10+
using Microsoft.Build.Locator;
1011
using Newtonsoft.Json;
1112

1213
/// <summary>
@@ -26,6 +27,7 @@ internal static void Main(string[] args)
2627
return;
2728
}
2829

30+
MSBuildLocator.RegisterDefaults();
2931
SolutionReader reader = SolutionReader.CreateAsync(args[0]).Result;
3032

3133
var diagnostics = reader.GetDiagnosticsAsync().Result;

StyleCop.Analyzers.Status.Generator/SolutionReader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ private async Task InitializeAsync()
177177
{
178178
this.solution = await this.workspace.OpenSolutionAsync(this.SlnPath);
179179

180-
this.analyzerProject = this.solution.Projects.Single(x => x.Name == this.AnalyzerProjectName);
180+
this.analyzerProject = this.solution.Projects.First(x => x.Name == this.AnalyzerProjectName || x.AssemblyName == this.AnalyzerProjectName);
181181
this.analyzerCompilation = await this.analyzerProject.GetCompilationAsync();
182182
this.analyzerCompilation = this.analyzerCompilation.WithOptions(this.analyzerCompilation.Options.WithOutputKind(OutputKind.DynamicallyLinkedLibrary));
183183

184-
this.codeFixProject = this.solution.Projects.Single(x => x.Name == this.CodeFixProjectName);
184+
this.codeFixProject = this.solution.Projects.First(x => x.Name == this.CodeFixProjectName || x.AssemblyName == this.CodeFixProjectName);
185185
this.codeFixCompilation = await this.codeFixProject.GetCompilationAsync();
186186
this.codeFixCompilation = this.codeFixCompilation.WithOptions(this.codeFixCompilation.Options.WithOutputKind(OutputKind.DynamicallyLinkedLibrary));
187187

@@ -210,7 +210,7 @@ private void InitializeCodeFixTypes()
210210

211211
private void Compile()
212212
{
213-
string path = Path.Combine(Path.GetDirectoryName(this.SlnPath), this.AnalyzerProjectName);
213+
string path = Path.GetDirectoryName(this.analyzerProject.FilePath);
214214
this.analyzerAssembly = this.GetAssembly(this.analyzerCompilation, ResourceReader.GetResourcesRecursive(path));
215215

216216
this.codeFixAssembly = this.GetAssembly(this.codeFixCompilation);

StyleCop.Analyzers.Status.Generator/StyleCop.Analyzers.Status.Generator.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33

44
<PropertyGroup>
5-
<TargetFramework>net452</TargetFramework>
5+
<TargetFramework>net46</TargetFramework>
66
<OutputType>Exe</OutputType>
77

88
<!-- Automatically generate the necessary assembly binding redirects -->
@@ -21,7 +21,9 @@
2121

2222
<ItemGroup>
2323
<PackageReference Include="LibGit2Sharp" Version="0.21.0.176" />
24-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="1.0.0" />
24+
<PackageReference Include="Microsoft.Build.Locator" Version="1.0.13" />
25+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.9.0-beta4-62830-01" />
26+
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="2.9.0-beta4-62830-01" />
2527
<PackageReference Include="Newtonsoft.Json" Version="7.0.1-beta3" />
2628
<PackageReference Include="StyleCop.Analyzers" Version="1.0.0-beta015" PrivateAssets="all" />
2729
</ItemGroup>

StyleCop.Analyzers.Status.Web/StyleCop.Analyzers.Status.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<AppDesignerFolder>Properties</AppDesignerFolder>
1414
<RootNamespace>StyleCop.Analyzers.Status.Web</RootNamespace>
1515
<AssemblyName>StyleCop.Analyzers.Status.Web</AssemblyName>
16-
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
16+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
1717
<MvcBuildViews>false</MvcBuildViews>
1818
<UseIISExpress>true</UseIISExpress>
1919
<IISExpressSSLPort />

0 commit comments

Comments
 (0)