mirror of
https://github.com/CommunityToolkit/dotnet.git
synced 2026-10-26 01:53:02 +08:00
41 lines
3.0 KiB
XML
41 lines
3.0 KiB
XML
<Project>
|
|
|
|
<PropertyGroup>
|
|
<TargetFramework>netstandard2.0</TargetFramework>
|
|
<IsPackable>false</IsPackable>
|
|
</PropertyGroup>
|
|
|
|
<!--
|
|
The MVVM Toolkit source generators rely on Roslyn multi-targeting to support multiple versions of the Microsoft.CodeAnalysis.CSharp package.
|
|
This package reference actually needs a matching version of Roslyn to be available for consumers of the source generator, so if we always
|
|
used the latest version, the MVVM Toolkit would just fail to load for users of eg. an older version of Visual Studio. Thankfully, Roslyn
|
|
supports analyzers that bundle multiple versions in the same NuGet package, each in a subfolder with a name matching the Roslyn version.
|
|
To leverage this, this project receives the MvvmToolkitSourceGeneratorRoslynVersion property as input, so that the MVVM Toolkit can build
|
|
it multiple times with multiple versions during packing, to then extract each .dll and copy it to the right NuGet package folder.
|
|
-->
|
|
<PropertyGroup>
|
|
|
|
<!-- Set the assembly name to always be the same, regardless of the Roslyn version being targeted (cut the trailing ".RoslynXYZ" suffix) -->
|
|
<AssemblyName>$(MSBuildProjectName.Substring(0, $([MSBuild]::Subtract($(MSBuildProjectName.Length), 10))))</AssemblyName>
|
|
|
|
<!--
|
|
Get the Roslyn version to use from the name of the project importing this .props file.
|
|
All projects will use the "<PROJECT_NAME>.Roslyn<MAJOR><MINOR><PATCH>.csproj" naming scheme.
|
|
-->
|
|
<MvvmToolkitSourceGeneratorRoslynMajorVersion>$(MSBuildProjectName.Substring($([MSBuild]::Subtract($(MSBuildProjectName.Length), 3)), 1))</MvvmToolkitSourceGeneratorRoslynMajorVersion>
|
|
<MvvmToolkitSourceGeneratorRoslynMinorVersion>$(MSBuildProjectName.Substring($([MSBuild]::Subtract($(MSBuildProjectName.Length), 2)), 1))</MvvmToolkitSourceGeneratorRoslynMinorVersion>
|
|
<MvvmToolkitSourceGeneratorRoslynPatchVersion>$(MSBuildProjectName.Substring($([MSBuild]::Subtract($(MSBuildProjectName.Length), 1)), 1))</MvvmToolkitSourceGeneratorRoslynPatchVersion>
|
|
<MvvmToolkitSourceGeneratorRoslynVersion>$(MvvmToolkitSourceGeneratorRoslynMajorVersion).$(MvvmToolkitSourceGeneratorRoslynMinorVersion).$(MvvmToolkitSourceGeneratorRoslynPatchVersion)</MvvmToolkitSourceGeneratorRoslynVersion>
|
|
|
|
<!-- Workaround for https://github.com/dotnet/roslyn/issues/63919 -->
|
|
<MvvmToolkitSourceGeneratorRoslynVersion Condition="'$(MvvmToolkitSourceGeneratorRoslynVersion)' == '4.3.0'">4.4.0-1.final</MvvmToolkitSourceGeneratorRoslynVersion>
|
|
|
|
<!-- Also define "ROSLYN_<MAJOR>_<MINOR>_OR_GREATER" build constants, so the generator code can multi-target whenever needed and add any required polyfills -->
|
|
<DefineConstants Condition="$([MSBuild]::VersionGreaterThanOrEquals($(MvvmToolkitSourceGeneratorRoslynVersion), 4.3))">$(DefineConstants);ROSLYN_4_3_0_OR_GREATER</DefineConstants>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup>
|
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MvvmToolkitSourceGeneratorRoslynVersion)" PrivateAssets="all" Pack="false" />
|
|
</ItemGroup>
|
|
|
|
</Project> |