Skip to content

Commit d8a442f

Browse files
committed
Streamline bundled .targets across TFMs
1 parent f3903a1 commit d8a442f

File tree

3 files changed

+12
-39
lines changed

3 files changed

+12
-39
lines changed

src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.FeatureSwitches.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
<!--
99
Configuration for the feature switches (to support IL trimming).
1010
See the 'ILLink.Substitutions.xml' file for more details on that.
11+
We only include these on .NET 6 and above (no .xml file otherwise).
1112
-->
12-
<ItemGroup>
13+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
1314

1415
<!-- MVVMTOOLKIT_ENABLE_INOTIFYPROPERTYCHANGING_SUPPORT switch -->
1516
<RuntimeHostConfigurationOption Include="MVVMTOOLKIT_ENABLE_INOTIFYPROPERTYCHANGING_SUPPORT"

src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -96,41 +96,13 @@
9696

9797
<ItemGroup Label="Package">
9898

99-
<!-- .NET Standard 2.0 only needs the Roslyn validation .targets -->
100-
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="buildTransitive\netstandard2.0" Pack="true" />
101-
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="buildTransitive\netstandard2.0" Pack="true" />
102-
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="build\netstandard2.0" Pack="true" />
103-
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="build\netstandard2.0" Pack="true" />
104-
105-
<!-- .NET Standard 2.0 does the same -->
106-
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="buildTransitive\netstandard2.1" Pack="true" />
107-
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="buildTransitive\netstandard2.1" Pack="true" />
108-
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="build\netstandard2.1" Pack="true" />
109-
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="build\netstandard2.1" Pack="true" />
110-
111-
<!-- .NET 6 also supports feature switches -->
112-
<None Include="CommunityToolkit.Mvvm.FeatureSwitches.targets" PackagePath="buildTransitive\net6.0" Pack="true" />
113-
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="buildTransitive\net6.0" Pack="true" />
114-
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="buildTransitive\net6.0" Pack="true" />
115-
<None Include="CommunityToolkit.Mvvm.FeatureSwitches.targets" PackagePath="build\net6.0" Pack="true" />
116-
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="build\net6.0" Pack="true" />
117-
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="build\net6.0" Pack="true" />
118-
119-
<!-- .NET 8 does the same as .NET 6 -->
120-
<None Include="CommunityToolkit.Mvvm.FeatureSwitches.targets" PackagePath="buildTransitive\net8.0" Pack="true" />
121-
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="buildTransitive\net8.0" Pack="true" />
122-
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="buildTransitive\net8.0" Pack="true" />
123-
<None Include="CommunityToolkit.Mvvm.FeatureSwitches.targets" PackagePath="build\net8.0" Pack="true" />
124-
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="build\net8.0" Pack="true" />
125-
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="build\net8.0" Pack="true" />
126-
127-
<!-- .NET 8 on Windows is the same as .NET 8 with respect to .targets -->
128-
<None Include="CommunityToolkit.Mvvm.FeatureSwitches.targets" PackagePath="buildTransitive\net8.0-windows10.0.17763.0" Pack="true" />
129-
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="buildTransitive\net8.0-windows10.0.17763.0" Pack="true" />
130-
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="buildTransitive\net8.0-windows10.0.17763.0" Pack="true" />
131-
<None Include="CommunityToolkit.Mvvm.FeatureSwitches.targets" PackagePath="build\net8.0-windows10.0.17763.0" Pack="true" />
132-
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="build\net8.0-windows10.0.17763.0" Pack="true" />
133-
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="build\net8.0-windows10.0.17763.0" Pack="true" />
99+
<!-- Include the custom .targets files (shared across TFMs) -->
100+
<None Include="CommunityToolkit.Mvvm.FeatureSwitches.targets" PackagePath="build" Pack="true" />
101+
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="build" Pack="true" />
102+
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="build" Pack="true" />
103+
<None Include="CommunityToolkit.Mvvm.FeatureSwitches.targets" PackagePath="buildTransitive" Pack="true" />
104+
<None Include="CommunityToolkit.Mvvm.SourceGenerators.targets" PackagePath="buildTransitive" Pack="true" />
105+
<None Include="CommunityToolkit.Mvvm.targets" PackagePath="buildTransitive" Pack="true" />
134106

135107
<!--
136108
Pack the source generator to the right package folders (each matching the target Roslyn version).

src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.targets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<_CommunityToolkitMvvmSourceGeneratorsTargets>$(MSBuildThisFileDirectory)CommunityToolkit.Mvvm.SourceGenerators.targets</_CommunityToolkitMvvmSourceGeneratorsTargets>
77
</PropertyGroup>
88

9-
<!-- Import all available .targets (NuGet only auto-imports the one whose name matches the package name) -->
10-
<Import Project="$(_CommunityToolkitMvvmFeatureSwitchesTargets)" Condition="Exists('$(_CommunityToolkitMvvmFeatureSwitchesTargets)')"/>
11-
<Import Project="$(_CommunityToolkitMvvmSourceGeneratorsTargets)" Condition="Exists('$(_CommunityToolkitMvvmSourceGeneratorsTargets)')"/>
9+
<!-- Import all available .targets -->
10+
<Import Project="$(_CommunityToolkitMvvmFeatureSwitchesTargets)" />
11+
<Import Project="$(_CommunityToolkitMvvmSourceGeneratorsTargets)" />
1212

1313
</Project>

0 commit comments

Comments
 (0)