Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
- name: Build
run: dotnet build --configuration ${{ env.CONFIGURATION }}

- name: Build Roslyn 4.4 variant
run: dotnet build src/DocoptNet/DocoptNet.csproj -f netstandard2.0 -p:RoslynVersion=4.4 --configuration ${{ env.CONFIGURATION }}

- name: Pack (Windows only)
if: runner.os == 'Windows'
shell: pwsh
Expand Down
37 changes: 34 additions & 3 deletions src/DocoptNet/DocoptNet.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<_Roslyn44AnalyzerDir>$(MSBuildProjectDirectory)/bin/roslyn4.4/</_Roslyn44AnalyzerDir>
</PropertyGroup>

<PropertyGroup Condition="'$(RoslynVersion)' == '4.4'">
<BaseOutputPath>$(_Roslyn44AnalyzerDir)</BaseOutputPath>
<BaseIntermediateOutputPath>$(MSBuildProjectDirectory)/obj/roslyn4.4/</BaseIntermediateOutputPath>
<DefaultItemExcludes>$(DefaultItemExcludes);$(MSBuildProjectDirectory)/obj/**</DefaultItemExcludes>
<DefineConstants>$(DefineConstants);ROSLYN4_4</DefineConstants>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netstandard2.1;netstandard2.0;net47</TargetFrameworks>
<DefineConstants>$(DefineConstants);DOCOPTNET_PUBLIC</DefineConstants>
Expand Down Expand Up @@ -49,14 +60,26 @@ Portions Copyright (C) West Wind Technologies, 2008.
<None Include="CodeGeneration\*.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net47'">
<ItemGroup Condition="'$(TargetFramework)' != 'net47' And '$(RoslynVersion)' != '4.4'">
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net47' And '$(RoslynVersion)' == '4.4'">
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net47'">
<AdditionalFiles Include="CodeGeneration\AnalyzerReleases.*.md" />
</ItemGroup>

<ItemGroup>
<!-- Package the generator in the analyzer directory of the nuget package -->
<None Include="$(OutputPath)\netstandard2.0\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<!-- Package the generator in the analyzer directory of the nuget package.
Using a versioned roslyn3.10/ folder instead of the unversioned cs/ path ensures the SDK
selects only the best-matching Roslyn variant (3.10 baseline or 4.4) rather than loading both.
See: https://github.com/dotnet/sdk/issues/20355 -->
<None Include="$(OutputPath)\netstandard2.0\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/roslyn3.10/cs" Visible="false" />
<!-- Package the Roslyn 4.4 variant of the generator -->
<None Include="$(_Roslyn44AnalyzerDir)$(Configuration)/netstandard2.0/$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/roslyn4.4/cs" Visible="false" />
<!--
Using a "PackagePath" of "build/$(TargetFramework)/%(Filename)%(Extension)" causes the
following error:
Expand Down Expand Up @@ -96,4 +119,12 @@ Portions Copyright (C) West Wind Technologies, 2008.
<AdditionalFiles Include="PublicAPI/$(TargetFramework)/PublicAPI.Unshipped.txt" />
</ItemGroup>

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

</Project>