File tree Expand file tree Collapse file tree 9 files changed +41
-17
lines changed Expand file tree Collapse file tree 9 files changed +41
-17
lines changed Original file line number Diff line number Diff line change 1515 </PropertyGroup >
1616
1717 <!--
18- .NET Standard 2.1 and .NET 6 already have [NotNullIfNotNull] and [NotNullWhen].
19- Additionally, also enable trimming support on .NET 6.
18+ Use NETSTANDARD2_1_OR_GREATER define to include .NET Standard 2.1 and .NET 6 shared APIs.
19+ They already have [NotNullIfNotNull] and [NotNullWhen] attributes built-in.
20+ Additionally, enable assembly trimming on .NET 6+.
2021 -->
2122 <PropertyGroup Condition =" '$(TargetFramework)' == 'net6.0'" >
2223 <DefineConstants >NETSTANDARD2_1_OR_GREATER</DefineConstants >
Original file line number Diff line number Diff line change 3131 </ItemGroup >
3232 </When >
3333
34- <!-- Enable trimming support on .NET 6 -->
34+ <!--
35+ Use NETSTANDARD2_1_OR_GREATER define to include .NET Standard 2.1 and .NET 6 shared APIs.
36+ Additionally, enable assembly trimming on .NET 6+.
37+ -->
3538 <When Condition =" '$(TargetFramework)' == 'net6.0'" >
3639 <PropertyGroup >
3740 <DefineConstants >NETSTANDARD2_1_OR_GREATER</DefineConstants >
4144 </When >
4245 </Choose >
4346
47+ <!--
48+ Adds support for generating sources using T4 text templating engine.
49+ The Guard APIs in 'Generated' folder is generated using text templates.
50+ -->
4451 <Import Project =" $(BuildToolsDirectory)Community.Toolkit.TextTemplates.targets" />
4552
4653</Project >
Original file line number Diff line number Diff line change 4646 </When >
4747
4848 <When Condition =" '$(TargetFramework)' == 'netcoreapp3.1'" >
49+
50+ <!-- Use NETSTANDARD2_1_OR_GREATER define to include shared APIs -->
4951 <PropertyGroup >
5052 <DefineConstants >NETSTANDARD2_1_OR_GREATER</DefineConstants >
5153 </PropertyGroup >
5759 </When >
5860
5961 <!--
60- NETSTANDARD2_1_OR_GREATER: includes both .NET Standard 2.1, .NET Core 3.1 and .NET 6.
61- Additionally, also enable trimming support on .NET 6.
62+ Use NETSTANDARD2_1_OR_GREATER define to include .NET Standard 2.1, .NET Core 3.1 and .NET 6 shared APIs .
63+ Additionally, enable assembly trimming on .NET 6+
6264 -->
6365 <When Condition =" '$(TargetFramework)' == 'net6.0'" >
6466 <PropertyGroup >
Original file line number Diff line number Diff line change 55 <TargetFramework >netstandard2.0</TargetFramework >
66 </PropertyGroup >
77
8+ <!-- Sources that are used by Generator logic in the target projects -->
89 <ItemGroup >
910 <Compile Remove =" EmbeddedResources\*.cs" />
1011 <EmbeddedResource Include =" EmbeddedResources\*.cs" CopyToOutputDirectory =" PreserveNewest" />
1112 </ItemGroup >
1213
14+ <!--
15+ These files enables tracking Analyzer releases for the rules that ship from this project.
16+ See https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md for more info.
17+ -->
1318 <ItemGroup >
1419 <AdditionalFiles Include =" AnalyzerReleases.Shipped.md" />
1520 <AdditionalFiles Include =" AnalyzerReleases.Unshipped.md" />
Original file line number Diff line number Diff line change 2020 <PackageTags >MVVM;Toolkit;MVVMToolkit;INotifyPropertyChanged;Observable;IOC;DI;Dependency Injection;Object Messaging;Extensions;Helpers</PackageTags >
2121 </PropertyGroup >
2222
23- <!-- Enable trimming support on .NET 6 -->
23+ <!-- Enable assembly trimming on .NET 6+ -->
2424 <PropertyGroup Condition =" '$(TargetFramework)' == 'net6.0'" >
2525 <EnableTrimAnalyzer >true</EnableTrimAnalyzer >
2626 <IsTrimmable >true</IsTrimmable >
2727 </PropertyGroup >
2828
2929 <!--
30- Include the custom . targets file to check the source generator.
31- . NET 6 is not needed as it guarantees Roslyn 4.x .
30+ Include a custom targets file to check the compiler version required for the source generator.
31+ It needs Roslyn 4.x and including the targets in . NET 6+ is not needed as it guarantees the same .
3232 -->
3333 <ItemGroup >
3434 <None Include =" CommunityToolkit.Mvvm.targets" Pack =" True" PackagePath =" build\netstandard2.0" />
5858 </ItemGroup >
5959
6060 <!--
61- Pack the source generator to the right package folder
61+ Pack the source generator build outputs to the correct package folder for it to be used as an analyzer.
62+
63+ HACK: The recommended way to pack is to get the build outputs using the project's built-in targets,
64+ and include them using NuGet's Pack targets. However, due to a bug in v5 of those targets,
65+ the outputs were not included in the package. So, including them directly via final
66+ output path and building it first is the only way to ensure they are included.
6267 -->
6368 <ItemGroup >
6469 <None Include =" ..\CommunityToolkit.Mvvm.SourceGenerators\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.SourceGenerators.dll"
Original file line number Diff line number Diff line change 11<Project >
22
3- <!-- Get the analyzer from the CommunityToolkit.Mvvm NuGet package -->
3+ <!-- Get the analyzer from the ' CommunityToolkit.Mvvm' NuGet package -->
44 <Target Name =" _MVVMToolkitGatherAnalyzers" >
55 <ItemGroup >
66 <_MVVMToolkitAnalyzer Include =" @(Analyzer)" Condition =" '%(Analyzer.NuGetPackageId)' == 'CommunityToolkit.Mvvm'" />
1414 DependsOnTargets =" _MVVMToolkitGatherAnalyzers" >
1515
1616 <!--
17- Use the CSharpCoreTargetsPath property to find the version of the compiler we are using. This is the same mechanism
17+ Use the ' CSharpCoreTargetsPath' property to find the version of the compiler we are using. This is the same mechanism
1818 MSBuild uses to find the compiler. We could check the assembly version for any compiler assembly (since they all have
19- the same version) but Microsoft.Build.Tasks.CodeAnalysis.dll is where MSBuild loads the compiler tasks from so if
19+ the same version) but ' Microsoft.Build.Tasks.CodeAnalysis.dll' is where MSBuild loads the compiler tasks from so if
2020 someone is getting creative with msbuild tasks/targets this is the "most correct" assembly to check.
2121 -->
2222 <GetAssemblyIdentity AssemblyFiles =" $([System.IO.Path]::Combine($([System.IO.Path]::GetDirectoryName($(CSharpCoreTargetsPath))), 'Microsoft.Build.Tasks.CodeAnalysis.dll'))" >
2323 <Output TaskParameter =" Assemblies" ItemName =" CurrentCompilerAssemblyIdentity" />
2424 </GetAssemblyIdentity >
2525
2626 <PropertyGroup >
27- <!-- Transform the resulting item from GetAssemblyIdentity into a property representing its assembly version -->
27+ <!-- Transform the resulting item from ' GetAssemblyIdentity' task into a property representing its assembly version -->
2828 <CurrentCompilerVersion >@(CurrentCompilerAssemblyIdentity->'%(Version)')</CurrentCompilerVersion >
2929
30- <!-- The CurrentCompilerVersionIsNotNewEnough property can now be defined based on the Roslyn assembly version -->
30+ <!-- The ' CurrentCompilerVersionIsNotNewEnough' property can now be defined based on the Roslyn assembly version -->
3131 <CurrentCompilerVersionIsNotNewEnough Condition =" $([MSBuild]::VersionLessThan($(CurrentCompilerVersion), 4.0))" >true</CurrentCompilerVersionIsNotNewEnough >
3232 </PropertyGroup >
3333
Original file line number Diff line number Diff line change 22
33 <Import Project =" $(BuildToolsDirectory)Community.Toolkit.Common.targets" />
44
5+ <!--
6+ Nerdbank.GitVersioning overwrites the 'InformationalVersion' that was supposed to hold the 'SourceRevisionId'.
7+ Hence, Add the 'SourceRevisionId' into the Assembly Metadata with the key 'CommitHash'.
8+ -->
59 <Target Name =" AddCommitHashToAssemblyAttributes" BeforeTargets =" GetAssemblyAttributes" >
610 <ItemGroup >
711 <AssemblyAttribute Include =" System.Reflection.AssemblyMetadataAttribute" Condition =" '$(SourceRevisionId)' != ''" >
Original file line number Diff line number Diff line change 1414 </PropertyGroup >
1515
1616 <PropertyGroup Condition =" $(IsPackable)" >
17- <!-- TODO: Dynamically generate Title if one wasn't set -->
1817 <Title Condition =" '$(Title)' == ''" >$(Product) Asset</Title >
1918 <PackageTags Condition =" '$(PackageTags)' != ''" >$(CommonTags);$(PackageTags)</PackageTags >
2019 <PackageTags Condition =" '$(PackageTags)' == ''" >$(CommonTags)</PackageTags >
Original file line number Diff line number Diff line change 55 </PropertyGroup >
66
77 <!--
8- Manually apply the properties of test projects to this assembly as well,
9- which is neither a test project not one of the libraries to pack for NuGet.
8+ The MVVM Toolkit unit tests use this project to test it as a `ProjectReference`.
9+ Since this project is neither packed nor published, those targets can be
10+ disabled, and validation warnings can be ignored in those contexts.
1011 -->
1112 <PropertyGroup >
1213 <IsPackable >false</IsPackable >
You can’t perform that action at this time.
0 commit comments