|
1 | 1 | <Project Sdk="Microsoft.NET.Sdk"> |
2 | 2 |
|
| 3 | + <PropertyGroup> |
| 4 | + <_Roslyn44AnalyzerDir>$(MSBuildProjectDirectory)/bin/roslyn4.4/</_Roslyn44AnalyzerDir> |
| 5 | + </PropertyGroup> |
| 6 | + |
| 7 | + <PropertyGroup Condition="'$(RoslynVersion)' == '4.4'"> |
| 8 | + <BaseOutputPath>$(_Roslyn44AnalyzerDir)</BaseOutputPath> |
| 9 | + <BaseIntermediateOutputPath>$(MSBuildProjectDirectory)/obj/roslyn4.4/</BaseIntermediateOutputPath> |
| 10 | + <DefaultItemExcludes>$(DefaultItemExcludes);$(MSBuildProjectDirectory)/obj/**</DefaultItemExcludes> |
| 11 | + <DefineConstants>$(DefineConstants);ROSLYN4_4</DefineConstants> |
| 12 | + </PropertyGroup> |
| 13 | + |
3 | 14 | <PropertyGroup> |
4 | 15 | <TargetFrameworks>netstandard2.1;netstandard2.0;net47</TargetFrameworks> |
5 | 16 | <DefineConstants>$(DefineConstants);DOCOPTNET_PUBLIC</DefineConstants> |
@@ -49,14 +60,26 @@ Portions Copyright (C) West Wind Technologies, 2008. |
49 | 60 | <None Include="CodeGeneration\*.cs" /> |
50 | 61 | </ItemGroup> |
51 | 62 |
|
52 | | - <ItemGroup Condition="'$(TargetFramework)' != 'net47'"> |
| 63 | + <ItemGroup Condition="'$(TargetFramework)' != 'net47' And '$(RoslynVersion)' != '4.4'"> |
53 | 64 | <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" PrivateAssets="all" /> |
| 65 | + </ItemGroup> |
| 66 | + |
| 67 | + <ItemGroup Condition="'$(TargetFramework)' != 'net47' And '$(RoslynVersion)' == '4.4'"> |
| 68 | + <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" /> |
| 69 | + </ItemGroup> |
| 70 | + |
| 71 | + <ItemGroup Condition="'$(TargetFramework)' != 'net47'"> |
54 | 72 | <AdditionalFiles Include="CodeGeneration\AnalyzerReleases.*.md" /> |
55 | 73 | </ItemGroup> |
56 | 74 |
|
57 | 75 | <ItemGroup> |
58 | | - <!-- Package the generator in the analyzer directory of the nuget package --> |
59 | | - <None Include="$(OutputPath)\netstandard2.0\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" /> |
| 76 | + <!-- Package the generator in the analyzer directory of the nuget package. |
| 77 | + Using a versioned roslyn3.10/ folder instead of the unversioned cs/ path ensures the SDK |
| 78 | + selects only the best-matching Roslyn variant (3.10 baseline or 4.4) rather than loading both. |
| 79 | + See: https://github.com/dotnet/sdk/issues/20355 --> |
| 80 | + <None Include="$(OutputPath)\netstandard2.0\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/roslyn3.10/cs" Visible="false" /> |
| 81 | + <!-- Package the Roslyn 4.4 variant of the generator --> |
| 82 | + <None Include="$(_Roslyn44AnalyzerDir)$(Configuration)/netstandard2.0/$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/roslyn4.4/cs" Visible="false" /> |
60 | 83 | <!-- |
61 | 84 | Using a "PackagePath" of "build/$(TargetFramework)/%(Filename)%(Extension)" causes the |
62 | 85 | following error: |
@@ -96,4 +119,12 @@ Portions Copyright (C) West Wind Technologies, 2008. |
96 | 119 | <AdditionalFiles Include="PublicAPI/$(TargetFramework)/PublicAPI.Unshipped.txt" /> |
97 | 120 | </ItemGroup> |
98 | 121 |
|
| 122 | + <Target Name="_ValidateRoslyn44AnalyzerOutput" BeforeTargets="GenerateNuspec"> |
| 123 | + <PropertyGroup> |
| 124 | + <_Roslyn44AnalyzerPath>$(_Roslyn44AnalyzerDir)$(Configuration)/netstandard2.0/$(AssemblyName).dll</_Roslyn44AnalyzerPath> |
| 125 | + </PropertyGroup> |
| 126 | + <Error Condition="!Exists('$(_Roslyn44AnalyzerPath)')" |
| 127 | + Text="Roslyn 4.4 analyzer output not found at '$(_Roslyn44AnalyzerPath)'. Build all Roslyn variants first by running: ./build.ps1 -Pack" /> |
| 128 | + </Target> |
| 129 | + |
99 | 130 | </Project> |
0 commit comments