Skip to content

Commit cafaaf9

Browse files
committed
✨ 新增多平台 MSBuild 属性文件支持跨平台构建
新增 TFM_NETX_WITH_ALL.props 和 TFM_NETX_WITH_ANDROID.props 两个 MSBuild 属性文件,实现对多目标框架(如 macos、windows、android、ios、maccatalyst 等)的支持。根据不同操作系统自动调整 TargetFrameworks、SupportedOSPlatformVersion、编译常量等属性,并引入 StyleCop.Analyzers 以提升代码规范性。优化了跨平台构建的灵活性和可维护性。
1 parent 5490244 commit cafaaf9

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/TFM_NETX_WITH_ALL.props

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project>
2+
<PropertyGroup>
3+
<TargetFrameworks>net$(DotNet_Version)</TargetFrameworks>
4+
<!--<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net$(DotNet_Version)-android;net$(DotNet_Version)-ios;net$(DotNet_Version)-macos;net$(DotNet_Version)-maccatalyst;net$(DotNet_Version)-windows$(WinSDK_Version)</TargetFrameworks>-->
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net$(DotNet_Version)-macos;net$(DotNet_Version)-windows$(WinSDK_Version)</TargetFrameworks>
6+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net$(DotNet_Version)-android;net$(DotNet_Version)-ios;net$(DotNet_Version)-macos;net$(DotNet_Version)-maccatalyst</TargetFrameworks>
7+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks)</TargetFrameworks>
8+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
9+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
10+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'macos'">10.15</SupportedOSPlatformVersion>
11+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
12+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
13+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
14+
<DefineConstants Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == ''">LINUX;$(DefineConstants)</DefineConstants>
15+
<DefineConstants Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'macos' OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">DISABLE_ASPNET_CORE;$(DefineConstants)</DefineConstants>
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" />
20+
</ItemGroup>
21+
</Project>

src/TFM_NETX_WITH_ANDROID.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!--<TargetFrameworks>net$(DotNet_Version);net$(DotNet_Version)-android</TargetFrameworks>-->
4+
<TargetFrameworks>net$(DotNet_Version)</TargetFrameworks>
5+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
6+
</PropertyGroup>
7+
</Project>

0 commit comments

Comments
 (0)