Skip to content

Commit

Permalink
Use fixed compilers package to target Roslyn 4.3
Browse files Browse the repository at this point in the history
- This effectively makes .NET 7 SDK irrelevant.
  It can be added later when migrating to .NET 7.

- Add the problematic Trim Analyzer to $(NoWarn)
  instead of completely disabling it.
  • Loading branch information
Nirmal4G committed Sep 21, 2022
1 parent 8b13049 commit 39ea152
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@
<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>

<!-- Mark the package reference implicit so it won't get updated during manual packages update -->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MvvmToolkitSourceGeneratorRoslynVersion)" PrivateAssets="all" Pack="false" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MvvmToolkitSourceGeneratorRoslynVersion)"
PrivateAssets="All" Pack="false" IsImplicitlyDefined="true" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@

<!-- Enable trimming support on .NET 6 -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">

<!-- Temporarily disabled as a workaround for https://github.com/dotnet/linker/issues/3032 -->
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>

<!-- Workaround for https://github.com/dotnet/linker/issues/3032 -->
<NoWarn>$(NoWarn);AD0001</NoWarn>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

Expand All @@ -59,10 +60,9 @@
<!--
Pack the source generator to the right package folders (each matching the target Roslyn version).
Roslyn will automatically load the highest version compatible with Roslyn's version in the SDK.
The Roslyn 4.3 target is copied to the 4.4 folder as a workaround for https://github.com/dotnet/roslyn/issues/63919.
-->
<None Include="..\CommunityToolkit.Mvvm.SourceGenerators.Roslyn401\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.SourceGenerators.dll" PackagePath="analyzers\dotnet\roslyn4.0\cs" Pack="true" Visible="false" />
<None Include="..\CommunityToolkit.Mvvm.SourceGenerators.Roslyn430\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.SourceGenerators.dll" PackagePath="analyzers\dotnet\roslyn4.4\cs" Pack="true" Visible="false" />
<None Include="..\CommunityToolkit.Mvvm.SourceGenerators.Roslyn430\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.SourceGenerators.dll" PackagePath="analyzers\dotnet\roslyn4.3\cs" Pack="true" Visible="false" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,12 @@
</When>
</Choose>

<!--
Fix for https://github.com/dotnet/roslyn/issues/63318
Workaound for https://github.com/dotnet/roslyn/issues/63780
-->
<ItemGroup Condition="'$(ContinuousIntegrationBuild)' != 'true'">
<PackageReference Include="Microsoft.NET.Compilers.ToolSet" Version="4.3.0-3.22470.13" PrivateAssets="All" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions Directory.Build.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-NoLogo
-MaxCPUCount
-NodeReuse:True
-Verbosity:Normal
13 changes: 13 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<packageSources>
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"/>
</packageSources>
<packageSourceMapping>
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet-tools">
<package pattern="Microsoft.NET.Compilers.ToolSet" />
</packageSource>
</packageSourceMapping>
</configuration>
8 changes: 0 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ jobs:
timeoutInMinutes: 60
steps:

# Install the .NET 7 SDK
- task: UseDotNet@2
displayName: Install the .NET 7 SDK
inputs:
version: 7.0.x
includePreviewVersions: true
performMultiLevelLookup: true

# Set Build Version
- script: nbgv cloud
displayName: Set NBGV version
Expand Down
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "6.0.400",
"rollForward": "latestFeature"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.MSTest" Version="1.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0-1.final" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
Expand Down

0 comments on commit 39ea152

Please sign in to comment.