|
9 | 9 |
|
10 | 10 | <!-- Remove the analyzer if using Roslyn 3.x (incremental generators require Roslyn 4.x) -->
|
11 | 11 | <Target Name="_MVVMToolkitRemoveAnalyzersForRoslyn3"
|
| 12 | + Condition="'$(CSharpCoreTargetsPath)' != ''" |
12 | 13 | AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets"
|
13 | 14 | DependsOnTargets="_MVVMToolkitGatherAnalyzers">
|
14 | 15 |
|
|
19 | 20 | <GetAssemblyIdentity AssemblyFiles="$([System.IO.Path]::Combine(`$([System.IO.Path]::GetDirectoryName($(CSharpCoreTargetsPath)))`,`Microsoft.Build.Tasks.CodeAnalysis.dll`))">
|
20 | 21 | <Output TaskParameter="Assemblies" ItemName="CurrentCompilerAssemblyIdentity"/>
|
21 | 22 | </GetAssemblyIdentity>
|
22 |
| - |
| 23 | + |
23 | 24 | <PropertyGroup>
|
24 | 25 |
|
25 | 26 | <!-- Transform the resulting item from GetAssemblyIdentity into a property representing its assembly version -->
|
26 | 27 | <CurrentCompilerVersion>@(CurrentCompilerAssemblyIdentity->'%(Version)')</CurrentCompilerVersion>
|
27 |
| - |
| 28 | + |
28 | 29 | <!-- The CurrentCompilerVersionIsNotNewEnough property can now be defined based on the Roslyn assembly version -->
|
29 | 30 | <CurrentCompilerVersionIsNotNewEnough Condition="$([MSBuild]::VersionLessThan($(CurrentCompilerVersion), 4.0))">true</CurrentCompilerVersionIsNotNewEnough>
|
30 |
| - <CurrentCompilerVersionIsNotNewEnough Condition="$(CurrentCompilerVersionIsNotNewEnough) == ''">false</CurrentCompilerVersionIsNotNewEnough> |
31 | 31 | </PropertyGroup>
|
32 |
| - |
| 32 | + |
33 | 33 | <!-- If the Roslyn version is < 4.0, disable the source generators -->
|
34 |
| - <ItemGroup Condition ="$(CurrentCompilerVersionIsNotNewEnough) == 'true'"> |
| 34 | + <ItemGroup Condition ="'$(CurrentCompilerVersionIsNotNewEnough)' == 'true'"> |
35 | 35 | <Analyzer Remove="@(_MVVMToolkitAnalyzer)"/>
|
36 | 36 | </ItemGroup>
|
37 |
| - |
| 37 | + |
38 | 38 | <!-- If the source generators are disabled, also emit a warning. This would've been produced by MSBuild itself as well, but
|
39 | 39 | emitting this manually lets us customize the message to inform developers as to why exactly the generators have been
|
40 | 40 | disabled, and that the rest of the MVVM Toolkit will still keep working as intended, just without additional features. -->
|
41 |
| - <Warning Condition ="$(CurrentCompilerVersionIsNotNewEnough) == 'true'" Text="The MVVM Toolkit source generators have been disabled on the current configuration, as they need Roslyn 4.x in order to work. The MVVM Toolkit will work just fine, but features relying on the source generators will not be available."/> |
| 41 | + <Warning Condition ="'$(CurrentCompilerVersionIsNotNewEnough)' == 'true'" Text="The MVVM Toolkit source generators have been disabled on the current configuration, as they need Roslyn 4.x in order to work. The MVVM Toolkit will work just fine, but features relying on the source generators will not be available."/> |
| 42 | + </Target> |
| 43 | + |
| 44 | + <!-- Remove the analyzer if Roslyn is missing --> |
| 45 | + <Target Name="_MVVMToolkitRemoveAnalyzersForRosynNotFound" |
| 46 | + Condition="'$(CSharpCoreTargetsPath)' == ''" |
| 47 | + AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets" |
| 48 | + DependsOnTargets="_MVVMToolkitGatherAnalyzers"> |
| 49 | + |
| 50 | + <!-- If no Roslyn assembly could be found, just remove the analyzer without emitting a warning --> |
| 51 | + <ItemGroup> |
| 52 | + <Analyzer Remove="@(_MVVMToolkitAnalyzer)"/> |
| 53 | + </ItemGroup> |
42 | 54 | </Target>
|
43 | 55 |
|
44 | 56 | </Project>
|
0 commit comments