Skip to content

Commit d9307d7

Browse files
Copilotatifaziz
andcommitted
Add RoslynVersion configuration in DocoptNet.csproj for multi-Roslyn support
Co-authored-by: atifaziz <20511+atifaziz@users.noreply.github.com>
1 parent ef49bf4 commit d9307d7

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/DocoptNet/DocoptNet.csproj

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

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+
314
<PropertyGroup>
415
<TargetFrameworks>netstandard2.1;netstandard2.0;net47</TargetFrameworks>
516
<DefineConstants>$(DefineConstants);DOCOPTNET_PUBLIC</DefineConstants>
@@ -49,14 +60,23 @@ Portions Copyright (C) West Wind Technologies, 2008.
4960
<None Include="CodeGeneration\*.cs" />
5061
</ItemGroup>
5162

52-
<ItemGroup Condition="'$(TargetFramework)' != 'net47'">
63+
<ItemGroup Condition="'$(TargetFramework)' != 'net47' And '$(RoslynVersion)' != '4.4'">
5364
<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'">
5472
<AdditionalFiles Include="CodeGeneration\AnalyzerReleases.*.md" />
5573
</ItemGroup>
5674

5775
<ItemGroup>
5876
<!-- Package the generator in the analyzer directory of the nuget package -->
5977
<None Include="$(OutputPath)\netstandard2.0\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
78+
<!-- Package the Roslyn 4.4 variant of the generator -->
79+
<None Include="$(_Roslyn44AnalyzerDir)$(Configuration)/netstandard2.0/$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/roslyn4.4/cs" Visible="false" />
6080
<!--
6181
Using a "PackagePath" of "build/$(TargetFramework)/%(Filename)%(Extension)" causes the
6282
following error:
@@ -96,4 +116,12 @@ Portions Copyright (C) West Wind Technologies, 2008.
96116
<AdditionalFiles Include="PublicAPI/$(TargetFramework)/PublicAPI.Unshipped.txt" />
97117
</ItemGroup>
98118

119+
<Target Name="_ValidateRoslyn44AnalyzerOutput" BeforeTargets="GenerateNuspec">
120+
<PropertyGroup>
121+
<_Roslyn44AnalyzerPath>$(_Roslyn44AnalyzerDir)$(Configuration)/netstandard2.0/$(AssemblyName).dll</_Roslyn44AnalyzerPath>
122+
</PropertyGroup>
123+
<Error Condition="!Exists('$(_Roslyn44AnalyzerPath)')"
124+
Text="Roslyn 4.4 analyzer output not found at '$(_Roslyn44AnalyzerPath)'. Build all Roslyn variants first by running: ./build.ps1 -Pack" />
125+
</Target>
126+
99127
</Project>

0 commit comments

Comments
 (0)