56 行
3.1 KiB
XML
56 行
3.1 KiB
XML
<Project>
|
|
|
|
<!-- Get the analyzer from the ComputeSharp.D2D1.Uwp NuGet package -->
|
|
<Target Name="_ComputeSharpD2D1UwpGatherAnalyzers">
|
|
<ItemGroup>
|
|
<_ComputeSharpD2D1UwpAnalyzer Include="@(Analyzer)" Condition="'%(Analyzer.NuGetPackageId)' == 'ComputeSharp.D2D1.Uwp'" />
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<!-- Remove the analyzer if using Roslyn < 4.11 (ComputeSharp.D2D1.Uwp's generators require Roslyn 4.11) -->
|
|
<Target Name="_ComputeSharpD2D1UwpRemoveAnalyzersForRoslyn3"
|
|
Condition="'$(CSharpCoreTargetsPath)' != ''"
|
|
AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets"
|
|
DependsOnTargets="_ComputeSharpD2D1UwpGatherAnalyzers">
|
|
|
|
<!--
|
|
Use the CSharpCoreTargetsPath property to find the version of the compiler we are using. This is the same mechanism
|
|
MSBuild uses to find the compiler. We could check the assembly version for any compiler assembly (since they all have
|
|
the same version) but Microsoft.Build.Tasks.CodeAnalysis.dll is where MSBuild loads the compiler tasks from so if
|
|
someone is getting creative with msbuild tasks/targets this is the "most correct" assembly to check.
|
|
-->
|
|
<GetAssemblyIdentity AssemblyFiles="$([System.IO.Path]::Combine(`$([System.IO.Path]::GetDirectoryName($(CSharpCoreTargetsPath)))`,`Microsoft.Build.Tasks.CodeAnalysis.dll`))">
|
|
<Output TaskParameter="Assemblies" ItemName="ComputeSharpD2D1UwpCurrentCompilerAssemblyIdentity"/>
|
|
</GetAssemblyIdentity>
|
|
|
|
<PropertyGroup>
|
|
|
|
<!-- Transform the resulting item from GetAssemblyIdentity into a property representing its assembly version -->
|
|
<ComputeSharpD2D1UwpCurrentCompilerVersion>@(ComputeSharpD2D1UwpCurrentCompilerAssemblyIdentity->'%(Version)')</ComputeSharpD2D1UwpCurrentCompilerVersion>
|
|
|
|
<!-- The CurrentCompilerVersionIsNotNewEnough property can now be defined based on the Roslyn assembly version -->
|
|
<ComputeSharpD2D1UwpCurrentCompilerVersionIsNotNewEnough Condition="$([MSBuild]::VersionLessThan($(ComputeSharpD2D1UwpCurrentCompilerVersion), 4.11))">true</ComputeSharpD2D1UwpCurrentCompilerVersionIsNotNewEnough>
|
|
</PropertyGroup>
|
|
|
|
<!-- If the Roslyn version is < 4.11, disable the source generators -->
|
|
<ItemGroup Condition ="'$(ComputeSharpD2D1UwpCurrentCompilerVersionIsNotNewEnough)' == 'true'">
|
|
<Analyzer Remove="@(_ComputeSharpD2D1UwpAnalyzer)"/>
|
|
</ItemGroup>
|
|
|
|
<!-- There is no need to emit a warning here, as this package is always a transitive dependency from ComputeSharp.D2D1, which does emit the warning -->
|
|
</Target>
|
|
|
|
<!-- Remove the analyzer if Roslyn is missing -->
|
|
<Target Name="_ComputeSharpD2D1UwpRemoveAnalyzersForRosynNotFound"
|
|
Condition="'$(CSharpCoreTargetsPath)' == ''"
|
|
AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets"
|
|
DependsOnTargets="_ComputeSharpD2D1UwpGatherAnalyzers">
|
|
|
|
<!-- If no Roslyn assembly could be found, just remove the analyzer without emitting a warning -->
|
|
<ItemGroup>
|
|
<Analyzer Remove="@(_ComputeSharpD2D1UwpAnalyzer)"/>
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
</Project>
|