Skip to content

Commit d255b32

Browse files
committed
Introduce targets to filter target frameworks
Relies on dotnet/msbuild#8350 to be active or not cause build errors when not enabled. This is largely still experimental and may change. Enables the ability for an invocation of an arcade build to only build a desired set of target frameworks. The primary consumer is source-build. This allows source-build to simply remove TFMs from the build that would require SBRPs without extensive changes in project files.
1 parent 1a8e179 commit d255b32

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/Microsoft.DotNet.Arcade.Sdk/tools/BeforeCommonTargets.CrossTargeting.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
<Import Project="$(_ArcadeOverriddenCustomBeforeMicrosoftCommonCrossTargetingTargets)" Condition="Exists('$(_ArcadeOverriddenCustomBeforeMicrosoftCommonCrossTargetingTargets)')"/>
55

66
<Import Project="Version.BeforeCommonTargets.targets"/>
7+
<Import Project="TargetFrameworkFilters.BeforeCommonTargets.targets"/>
78
</Project>

src/Microsoft.DotNet.Arcade.Sdk/tools/BeforeCommonTargets.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
</PropertyGroup>
99

1010
<Import Project="Version.BeforeCommonTargets.targets"/>
11+
<Import Project="TargetFrameworkFilters.BeforeCommonTargets.targets"/>
1112
</Project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
3+
<Project>
4+
<PropertyGroup>
5+
<!-- Obtain the original set based on whether TargetFramework or TargetFrameworks was used -->
6+
<_EnableTargetFrameworkFiltering>false</_EnableTargetFrameworkFiltering>
7+
<_EnableTargetFrameworkFiltering Condition="'$(NoTargetFrameworkFiltering)' != 'true' and '$(DotNetTargetFrameworkFilter)' != ''">true</_EnableTargetFrameworkFiltering>
8+
</PropertyGroup>
9+
10+
<PropertyGroup Condition="$(_EnableTargetFrameworkFiltering)">
11+
<_OriginalTargetFrameworks Condition="'$(TargetFrameworks)' != ''">$(TargetFrameworks)</_OriginalTargetFrameworks>
12+
<_OriginalTargetFrameworks Condition="'$(TargetFramework)' != ''">$(TargetFramework)</_OriginalTargetFrameworks>
13+
<_FilteredTargetFrameworks>$([MSBuild]::Unescape($([MSBuild]::IntersectTargetFrameworks('$(_OriginalTargetFrameworks)', '$(DotNetTargetFrameworkFilter)'))))</_FilteredTargetFrameworks>
14+
<!-- Maintain usage of the original property, -->
15+
<TargetFrameworks Condition="'$(TargetFrameworks)' != ''">$(_FilteredTargetFrameworks)</TargetFrameworks>
16+
<TargetFramework Condition="'$(TargetFramework)' != ''">$(_FilteredTargetFrameworks)</TargetFramework>
17+
<ExcludeFromBuild Condition="'$(_FilteredTargetFrameworks)' == ''">true</ExcludeFromBuild>
18+
</PropertyGroup>
19+
20+
</Project>

0 commit comments

Comments
 (0)