chore: add target framework override capabilities

This commit is contained in:
Steve Bilogan 2022-09-14 12:13:01 -04:00
Родитель 2b197004df
Коммит e3019117fd
6 изменённых файлов: 87 добавлений и 13 удалений

4
.gitignore поставляемый
Просмотреть файл

@ -331,4 +331,6 @@ ASALocalRun/
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
.mfractor/
crosstargeting_override.props

Просмотреть файл

@ -44,4 +44,5 @@
</When>
</Choose>
<Import Project="Uno.CrossTargeting.props" />
</Project>

32
Uno.CrossTargeting.props Normal file
Просмотреть файл

@ -0,0 +1,32 @@
<Project ToolsVersion="15.0">
<Import Project="$(SolutionDir)\crosstargeting_override.props" Condition="exists('$(SolutionDir)\crosstargeting_override.props')" />
<Target Name="_DisplayTargets" BeforeTargets="BeforeBuild">
<Message Text="Building target framework: $(TargetFramework)" Importance="high" Condition="'$(TargetFramework)'!=''" />
</Target>
<Target Name="_UnoOverrideNuget" AfterTargets="AfterBuild" DependsOnTargets="BuiltProjectOutputGroup" Condition="'$(NugetOverrideVersion)'!=''">
<PropertyGroup>
<_TargetNugetPackageId Condition="'$(PackageId)'!=''">$(PackageId)</_TargetNugetPackageId>
<_TargetNugetPackageId Condition="'$(PackageId)'==''">$(AssemblyName)</_TargetNugetPackageId>
<_TargetNugetFolderBase>$(USERPROFILE)\.nuget\packages\$(_TargetNugetPackageId)\$(NugetOverrideVersion)\lib</_TargetNugetFolderBase>
<_TargetNugetFolder>$(_TargetNugetFolderBase)\$(TargetFramework)</_TargetNugetFolder>
</PropertyGroup>
<ItemGroup>
<_OutputFiles Include="@(BuiltProjectOutputGroupOutput)" />
<_OutputFilesPDB Include="@(_OutputFiles->'%(RootDir)\%(Directory)\%(RecursiveDir)%(Filename).pdb')" Condition="Exists('@(BuiltProjectOutputGroupOutput->'%(RootDir)\%(Directory)\%(RecursiveDir)%(Filename).pdb')')" />
</ItemGroup>
<MakeDir Directories="$(_TargetNugetFolder)\" />
<Message Importance="high" Text="OVERRIDING NUGET PACKAGE CACHE: $(_TargetNugetFolder) [and $(TargetPlatformVersion)]" />
<Copy SourceFiles="@(_OutputFiles)" DestinationFiles="@(_OutputFiles->'$(_TargetNugetFolder)\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(_OutputFilesPDB)" DestinationFiles="@(_OutputFilesPDB->'$(_TargetNugetFolder)\%(RecursiveDir)%(Filename).pdb')" />
<Copy Condition="'$(TargetPlatformVersion)'!=''" SourceFiles="@(_OutputFiles)" DestinationFiles="@(_OutputFiles->'$(_TargetNugetFolder)$(TargetPlatformVersion)\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy Condition="'$(TargetPlatformVersion)'!=''" SourceFiles="@(_OutputFilesPDB)" DestinationFiles="@(_OutputFilesPDB->'$(_TargetNugetFolder)$(TargetPlatformVersion)\%(RecursiveDir)%(Filename).pdb')" />
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,37 @@
<Project ToolsVersion="15.0">
<PropertyGroup>
<!--
This property allows the override of the nuget local cache.
Set it to the version you want to override, used in another app.
You will see the override path in the build output.
The packages are located under this directory: "%USERPROFILE%\.nuget\packages".
-->
<!-- <NugetOverrideVersion>1.0.0-dev.1</NugetOverrideVersion> -->
<!--
This property is used to control the platforms compiled by Visual Studio, and
allows for a faster build when testing for a single platform.
Instructions:
1) Copy this file and remove the ".sample" name
2) Adjust the NugetOverrideVersion property below
3) Make sure to do a Rebuild, so that nuget restores the proper packages for the new target
Available build targets
uap10.0.18362 (Windows)
net5.0-windows10.0.18362 (WinAppSDK Windows)
xamarinios10 (iOS)
MonoAndroid11.0 (Android 11.0)
netstandard2.0 (WebAssembly, Skia)
net6.0-ios (.NET 6 iOS)
net6.0-android (.NET 6 Android)
net6.0-maccatalyst (.NET 6 macOS Catalyst)
net6.0-macos (.NET 6 macOS AppKit)
xamarinmac20 (macOS)
Include netstandard2.0 to make sure all projects build
-->
<!-- <TargetFrameworkOverride>netstandard2.0;uap10.0.18362</TargetFrameworkOverride> -->
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;xamarinios10;monoandroid11.0;xamarinmac20</TargetFrameworks>
<TargetFrameworks Condition="'$(DisableNet6MobileTargets)'==''">$(TargetFrameworks);net6.0-ios;net6.0-macos;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworkOverride)'!=''">$(TargetFrameworkOverride)</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworkOverride)'==''">netstandard2.0;xamarinios10;monoandroid11.0;xamarinmac20</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworkOverride)'=='' and '$(DisableNet6MobileTargets)'!='true'">$(TargetFrameworks);net6.0-ios;net6.0-macos;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
<AllowedOutputExtensionsInPackageBuildOutputFolder>.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
@ -45,7 +46,7 @@
<DefineConstants>$(DefineConstants);WinUI</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)'=='net5.0-windows10.0.18362'">$(DefineConstants);WinUI_Desktop</DefineConstants>
<PackageId>Uno.Cupertino.WinUI</PackageId>
<TargetFrameworks>$(TargetFrameworks);net5.0-windows10.0.18362</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworkOverride)'=='' and '$(OS)'=='Windows_NT'">$(TargetFrameworks);net5.0-windows10.0.18362</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
@ -82,7 +83,7 @@
<PropertyGroup>
<PackageId>Uno.Cupertino</PackageId>
<TargetFrameworks Condition="'$(OS)'=='Windows_NT'">$(TargetFrameworks);uap10.0.18362</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworkOverride)'=='' and '$(OS)'=='Windows_NT'">$(TargetFrameworks);uap10.0.18362</TargetFrameworks>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;xamarinios10;monoandroid11.0;xamarinmac20</TargetFrameworks>
<TargetFrameworks Condition="'$(DisableNet6MobileTargets)'==''">$(TargetFrameworks);net6.0-ios;net6.0-macos;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworkOverride)'!=''">$(TargetFrameworkOverride)</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworkOverride)'==''">netstandard2.0;xamarinios10;monoandroid11.0;xamarinmac20</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworkOverride)'=='' and '$(DisableNet6MobileTargets)'!='true'">$(TargetFrameworks);net6.0-ios;net6.0-macos;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
<AllowedOutputExtensionsInPackageBuildOutputFolder>.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
@ -50,7 +51,7 @@
<DefineConstants>$(DefineConstants);WinUI</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)'=='net5.0-windows10.0.18362'">$(DefineConstants);WinUI_Desktop</DefineConstants>
<PackageId>Uno.Material.WinUI</PackageId>
<TargetFrameworks>$(TargetFrameworks);net5.0-windows10.0.18362</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworkOverride)'=='' and '$(OS)'=='Windows_NT'">$(TargetFrameworks);net5.0-windows10.0.18362</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
@ -93,7 +94,7 @@
<Otherwise>
<PropertyGroup>
<PackageId>Uno.Material</PackageId>
<TargetFrameworks Condition="'$(OS)'=='Windows_NT'">$(TargetFrameworks);uap10.0.18362</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworkOverride)'=='' and '$(OS)'=='Windows_NT'">$(TargetFrameworks);uap10.0.18362</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
@ -138,9 +139,9 @@
</ItemGroup>
<ItemGroup>
<None Remove="Styles\Application\Common\Fonts.xaml" />
<None Remove="Styles\Controls\v1\_Resources.xaml" />
<None Remove="Styles\Controls\v2\_Resources.xaml" />
<None Remove="Styles\Application\Common\Fonts.xaml" />
<None Remove="Styles\Controls\v1\_Resources.xaml" />
<None Remove="Styles\Controls\v2\_Resources.xaml" />
</ItemGroup>
<ItemGroup>
@ -183,7 +184,7 @@
<XamlMergeInput Remove="Styles\Application\v2\SharedColors.xaml" />
<XamlMergeInput Remove="Styles\Application\v2\SharedColorPalette.xaml" />
<XamlMergeInput Remove="Styles\Application\Common\Fonts.xaml" />
<XamlMergeInput Remove="Styles\Controls\v1\NavigationView\WUX\**" Condition="'$(UseWinUI)'=='true'" />
<Page Remove="Styles\Controls\v1\NavigationView\WUX\**" Condition="'$(UseWinUI)'=='true'" />