Skip to content

Commit

Permalink
chore: Adjusting conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrandolph committed Nov 13, 2023
1 parent fdc05ed commit 8a0321e
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
inputs:
solution: ./MyExtensionsApp._1.Tests/MyExtensionsApp._1.Tests.csproj
configuration: 'Release'
msbuildArguments: '/p:OverrideTargetFrameworks=$baseTargetFramework$ /r'
msbuildArguments: '/p:OverrideTargetFramework=$baseTargetFramework$ /r'

- task: VSTest@3
inputs:
Expand Down
18 changes: 0 additions & 18 deletions src/Uno.Templates/content/unoapp/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,4 @@
<!-- Removes native usings to avoid Ambiguous reference -->
<Using Remove="@(Using->HasMetadata('Platform'))" />
</ItemGroup>

<Target Name="ValidateOverrides" BeforeTargets="Restore;_CheckForUnsupportedTargetFramework" Condition="'$(OverrideTargetFrameworks)' != ''">
<Error
Text="OverrideTargetFrameworks set to '$(OverrideTargetFrameworks)' is missing Windows target. Either add $baseTargetFramework$-windows10.0.19041.0 to OverrideTargetFrameworks in solution-config.props, or skip building this project (eg unload the project in Visual Studio)"
Condition="$(TargetFramework.Contains('windows10')) and !$(OverrideTargetFrameworks.Contains('windows'))" />
<Error
Text="$(TargetFramework) OverrideTargetFrameworks set to '$(OverrideTargetFrameworks)' is missing iOS. Either add $baseTargetFramework$-ios to OverrideTargetFrameworks in solution-config.props, or skip building this project (eg unload the project in Visual Studio)"
Condition="('$(TargetFramework)'=='' and '$(TargetFrameworks)'=='') or ( $(TargetFrameworks.Contains('ios')) and !$(OverrideTargetFrameworks.Contains('ios')) )"/>
<Error
Text="$(TargetFramework) OverrideTargetFrameworks set to '$(OverrideTargetFrameworks)' is missing Android. Either add $baseTargetFramework$-android to OverrideTargetFrameworks in solution-config.props, or skip building this project (eg unload the project in Visual Studio)"
Condition="('$(TargetFramework)'=='' and '$(TargetFrameworks)'=='') or ( $(TargetFrameworks.Contains('android')) and !$(OverrideTargetFrameworks.Contains('android')) )"/>
<Error
Text="$(TargetFramework) OverrideTargetFrameworks set to '$(OverrideTargetFrameworks)' is missing MacOS. Either add $baseTargetFramework$-macos to OverrideTargetFrameworks in solution-config.props, or skip building this project (eg unload the project in Visual Studio)"
Condition="('$(TargetFramework)'=='' and '$(TargetFrameworks)'=='') or ( $(TargetFrameworks.Contains('macos')) and !$(OverrideTargetFrameworks.Contains('macos')) )"/>
<Error
Text="$(TargetFramework) OverrideTargetFrameworks set to '$(OverrideTargetFrameworks)' is missing MacCatalyst. Either add $baseTargetFramework$-maccatalyst to OverrideTargetFrameworks in solution-config.props, or skip building this project (eg unload the project in Visual Studio)"
Condition="('$(TargetFramework)'=='' and '$(TargetFrameworks)'=='') or ( $(TargetFrameworks.Contains('maccatalyst')) and !$(OverrideTargetFrameworks.Contains('maccatalyst')) )"/>
</Target>
</Project>
2 changes: 1 addition & 1 deletion src/Uno.Templates/content/unoapp/GitHub/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:

- name: Build MyExtensionsApp._1.Tests (Release)
shell: pwsh
run: msbuild ./MyExtensionsApp._1.Tests/MyExtensionsApp._1.Tests.csproj /p:Configuration=Release /p:OverrideTargetFrameworks=$baseTargetFramework$ /r
run: msbuild ./MyExtensionsApp._1.Tests/MyExtensionsApp._1.Tests.csproj /p:Configuration=Release /p:OverrideTargetFramework=$baseTargetFramework$ /r

- name: Run Unit Tests
shell: pwsh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

<PropertyGroup>
<!--#if (useWinAppSdk) -->
<TargetFrameworks Condition="'$(OverrideTargetFrameworks)'=='' and ($([MSBuild]::IsOSPlatform('windows')) or '$(EnableWindowsTargeting)' == 'true')">$(TargetFrameworks);$(DotNetVersion)-windows10.0.19041</TargetFrameworks>
<TargetFrameworks Condition="'$(OverrideTargetFrameworks)'==''">$(TargetFrameworks);$(DotNetVersion);$mobileTargetFrameworks$</TargetFrameworks>
<TargetFrameworks Condition="($([MSBuild]::IsOSPlatform('windows')) or '$(EnableWindowsTargeting)' == 'true')">$(TargetFrameworks);$(DotNetVersion)-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);$(DotNetVersion);$mobileTargetFrameworks$</TargetFrameworks>
<!--#else -->
<TargetFrameworks Condition="'$(OverrideTargetFrameworks)'==''">$(DotNetVersion);$mobileTargetFrameworks$</TargetFrameworks>
<TargetFrameworks>$(DotNetVersion);$mobileTargetFrameworks$</TargetFrameworks>
<!--#endif -->
<TargetFrameworks Condition="$(OverrideTargetFrameworks.Contains('ios'))">$(TargetFrameworks);$(DotNetVersion)-ios</TargetFrameworks>
<TargetFrameworks Condition="$(OverrideTargetFrameworks.Contains('android'))">$(TargetFrameworks);$(DotNetVersion)-android</TargetFrameworks>
<TargetFrameworks Condition="$(OverrideTargetFrameworks.Contains('maccatalyst'))">$(TargetFrameworks);$(DotNetVersion)-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$(OverrideTargetFrameworks.Contains('macos'))">$(TargetFrameworks);$(DotNetVersion)-macos</TargetFrameworks>
<TargetFrameworks Condition="'$(OverrideTargetFramework)'!=''">$(OverrideTargetFramework)</TargetFrameworks>

<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<!--#if (unoMauiClassLibrary)-->
<DotNetVersion Condition="'$(DotNetVersion)'==''">$baseTargetFramework$</DotNetVersion>
<!--#endif-->
</PropertyGroup>
<!--#if (unoMauiClassLibrary)-->

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks Condition="'$(OverrideTargetFrameworks)'==''">$mobileTargetFrameworks$</TargetFrameworks>
<TargetFrameworks>$mobileTargetFrameworks$</TargetFrameworks>
<!--#if (useMacOS)-->
<!-- Disabled because of https://github.com/xamarin/xamarin-macios/issues/16401-->
<!-- <TargetFrameworks Condition="'$(OverrideTargetFrameworks)'==''">$(TargetFrameworks);$(DotNetVersion)-macos</TargetFrameworks> -->
<!-- <TargetFrameworks>$(TargetFrameworks);$(DotNetVersion)-macos</TargetFrameworks> -->
<!--#endif-->
<TargetFrameworks Condition="$(OverrideTargetFrameworks.Contains('ios'))">$(TargetFrameworks);$(DotNetVersion)-ios</TargetFrameworks>
<TargetFrameworks Condition="$(OverrideTargetFrameworks.Contains('android'))">$(TargetFrameworks);$(DotNetVersion)-android</TargetFrameworks>
<TargetFrameworks Condition="$(OverrideTargetFrameworks.Contains('maccatalyst'))">$(TargetFrameworks);$(DotNetVersion)-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$(OverrideTargetFrameworks.Contains('macos'))">$(TargetFrameworks);$(DotNetVersion)-macos</TargetFrameworks>
<TargetFrameworks Condition="'$(OverrideTargetFramework)'!=''">$(OverrideTargetFramework)</TargetFrameworks>
<SingleProject>true</SingleProject>
<OutputType>Exe</OutputType>
<!-- Display name -->
Expand Down Expand Up @@ -277,4 +274,10 @@
<!--#endif-->
</ItemGroup>
<Import Project="..\MyExtensionsApp._1.Shared\base.props" />

<Target Name="ValidateOverrides" BeforeTargets="Restore;_CheckForUnsupportedTargetFramework" Condition="'$(OverrideTargetFramework)' != ''">
<Error
Text="OverrideTargetFramework set to '$(OverrideTargetFramework)' is missing valid target. Set OverrideTargetFramework to $baseTargetFramework$-ios, $baseTargetFramework$-android or $baseTargetFramework$-maccatalyst or skip building this project (eg unload the project in Visual Studio)"
Condition="'$(OverrideTargetFramework)'=='$(DotNetVersion)-windows10.0.19041.0' or '$(OverrideTargetFramework)'=='$(DotNetVersion)'" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,10 @@
<!--#endif-->
</ItemGroup>
<Import Project="..\MyExtensionsApp._1.Shared\base.props" />

<Target Name="ValidateOverrides" BeforeTargets="Restore;_CheckForUnsupportedTargetFramework" Condition="'$(OverrideTargetFramework)' != ''">
<Error
Text="OverrideTargetFramework set to '$(OverrideTargetFramework)' is invalid. Set OverrideTargetFramework to $baseTargetFramework$ or skip building this project (eg unload the project in Visual Studio)"
Condition="'$(OverrideTargetFramework)'!='$(DotNetVersion)'" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,10 @@
<!--#endif-->
</ItemGroup>
<Import Project="..\MyExtensionsApp._1.Shared\base.props" />

<Target Name="ValidateOverrides" BeforeTargets="Restore;_CheckForUnsupportedTargetFramework" Condition="'$(OverrideTargetFramework)' != ''">
<Error
Text="OverrideTargetFramework set to '$(OverrideTargetFramework)' is invalid. Set OverrideTargetFramework to $baseTargetFramework$ or skip building this project (eg unload the project in Visual Studio)"
Condition="'$(OverrideTargetFramework)'!='$(DotNetVersion)'" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,10 @@
<!--#endif-->
</ItemGroup>
<Import Project="..\MyExtensionsApp._1.Shared\base.props" />

<Target Name="ValidateOverrides" BeforeTargets="Restore;_CheckForUnsupportedTargetFramework" Condition="'$(OverrideTargetFramework)' != ''">
<Error
Text="OverrideTargetFramework set to '$(OverrideTargetFramework)' is invalid. Set OverrideTargetFramework to $baseTargetFramework$ or skip building this project (eg unload the project in Visual Studio)"
Condition="'$(OverrideTargetFramework)'!='$(DotNetVersion)'" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,10 @@
<!--#endif-->
</ItemGroup>
<Import Project="..\MyExtensionsApp._1.Shared\base.props" />

<Target Name="ValidateOverrides" BeforeTargets="Restore;_CheckForUnsupportedTargetFramework" Condition="'$(OverrideTargetFramework)' != ''">
<Error
Text="OverrideTargetFramework set to '$(OverrideTargetFramework)' is invalid. Set OverrideTargetFramework to $baseTargetFramework$ or skip building this project (eg unload the project in Visual Studio)"
Condition="'$(OverrideTargetFramework)'!='$(DotNetVersion)'" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,10 @@
</PropertyGroup>

<Import Project="..\MyExtensionsApp._1.Shared\base.props" />

<Target Name="ValidateOverrides" BeforeTargets="Restore;_CheckForUnsupportedTargetFramework" Condition="'$(OverrideTargetFramework)' != ''">
<Error
Text="OverrideTargetFramework set to '$(OverrideTargetFramework)' is missing Windows target. Set OverrideTargetFramework to $baseTargetFramework$-windows10.0.19041.0 or skip building this project (eg unload the project in Visual Studio)"
Condition="'$(OverrideTargetFramework)'!='$(DotNetVersion)-windows10.0.19041.0'" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- Disabled because of https://github.com/xamarin/xamarin-macios/issues/16401-->
<!--<TargetFrameworks>$(TargetFrameworks);$(DotNetVersion)-macos</TargetFrameworks>-->
<!--#endif -->
<TargetFrameworks Condition="'$(OverrideTargetFrameworks)'!=''">$(OverrideTargetFrameworks)</TargetFrameworks>
<TargetFrameworks Condition="'$(OverrideTargetFramework)'!=''">$(OverrideTargetFramework)</TargetFrameworks>

<!-- Ensures the .xr.xml files are generated in a proper layout folder -->
<GenerateLibraryLayout>true</GenerateLibraryLayout>
Expand Down
11 changes: 6 additions & 5 deletions src/Uno.Templates/content/unoapp/solution-config.props.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
This file is used to control the platforms compiled by Visual Studio, and allow for a faster
build when testing for a single platform. This will also result in better intellisense, as
the compiler will only load the assemblies for the platforms that are being built. You do not
the compiler will only load the assemblies for the platform that is being built. You do not
need to use this when compiling from Visual Studio Code, the command line or other IDEs.

Instructions:
Expand All @@ -21,9 +21,10 @@
<PropertyGroup>
<!-- Uncomment each line for each platform that you want to build: -->

<!-- <OverrideTargetFrameworks Condition="''!='hint: Windows App Sdk (WinUI)'">$baseTargetFramework$-windows10.0.19041.0</OverrideTargetFrameworks> -->
<!-- <OverrideTargetFrameworks Condition="''!='hint: iOS'">$baseTargetFramework$-ios</OverrideTargetFrameworks> -->
<!-- <OverrideTargetFrameworks Condition="''!='hint: Android'">$baseTargetFramework$-android</OverrideTargetFrameworks> -->
<!-- <OverrideTargetFrameworks Condition="''!='hint: MacCatalyst'">$baseTargetFramework$-maccatalyst</OverrideTargetFrameworks> -->
<!-- <OverrideTargetFramework Condition="''!='hint: Windows App Sdk (WinUI)'">$baseTargetFramework$-windows10.0.19041.0</OverrideTargetFramework> -->
<!-- <OverrideTargetFramework Condition="''!='hint: WASM, Skia'">$baseTargetFramework$</OverrideTargetFramework> -->
<!-- <OverrideTargetFramework Condition="''!='hint: iOS'">$baseTargetFramework$-ios</OverrideTargetFramework> -->
<!-- <OverrideTargetFramework Condition="''!='hint: Android'">$baseTargetFramework$-android</OverrideTargetFramework> -->
<!-- <OverrideTargetFramework Condition="''!='hint: MacCatalyst'">$baseTargetFramework$-maccatalyst</OverrideTargetFramework> -->
</PropertyGroup>
</Project>
59 changes: 15 additions & 44 deletions src/Uno.Templates/content/unomauilib/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
]
}
},
// TODO: Should we be using $(DotNetVersion) instead of explicitly defining each tfm?
"mobileTargetFrameworks": {
"type": "generated",
"generator": "switch",
Expand All @@ -122,63 +121,35 @@
"datatype": "string",
"cases": [
{
"condition": "(tfm == 'net7.0' && useAndroid && useiOS && useMacCatalyst)",
"value": "net7.0-android;net7.0-ios;net7.0-maccatalyst"
"condition": "(platforms == android && platforms == ios && platforms == maccatalyst)",
"value": "$(DotNetVersion)-android;$(DotNetVersion)-ios;$(DotNetVersion)-maccatalyst"
},
{
"condition": "(tfm == 'net8.0' && useAndroid && useiOS && useMacCatalyst)",
"value": "net8.0-android;net8.0-ios;net8.0-maccatalyst"
"condition": "(platforms == android && platforms == ios && platforms != maccatalyst)",
"value": "$(DotNetVersion)-android;$(DotNetVersion)-ios"
},
{
"condition": "(tfm == 'net7.0' && useAndroid && useiOS && !useMacCatalyst)",
"value": "net7.0-android;net7.0-ios"
"condition": "(platforms != android && platforms == ios && platforms == maccatalyst)",
"value": "$(DotNetVersion)-ios;$(DotNetVersion)-maccatalyst"
},
{
"condition": "(tfm == 'net8.0' && useAndroid && useiOS && !useMacCatalyst)",
"value": "net8.0-android;net8.0-ios"
"condition": "(platforms == android && platforms != ios && platforms == maccatalyst)",
"value": "$(DotNetVersion)-android;$(DotNetVersion)-maccatalyst"
},
{
"condition": "(tfm == 'net7.0' && !useAndroid && useiOS && useMacCatalyst)",
"value": "net7.0-ios;net7.0-maccatalyst"
"condition": "(platforms == android && platforms != ios && platforms != maccatalyst)",
"value": "$(DotNetVersion)-android"
},
{
"condition": "(tfm == 'net8.0' && !useAndroid && useiOS && useMacCatalyst)",
"value": "net8.0-ios;net8.0-maccatalyst"
"condition": "(platforms != android && platforms == ios && platforms != maccatalyst)",
"value": "$(DotNetVersion)-ios"
},
{
"condition": "(tfm == 'net7.0' && useAndroid && !useiOS && useMacCatalyst)",
"value": "net7.0-android;net7.0-maccatalyst"
"condition": "(platforms != android && platforms != ios && platforms == maccatalyst)",
"value": "$(DotNetVersion)-maccatalyst"
},
{
"condition": "(tfm == 'net8.0' && useAndroid && !useiOS && useMacCatalyst)",
"value": "net8.0-android;net8.0-maccatalyst"
},
{
"condition": "(tfm == 'net7.0' && useAndroid && !useiOS && !useMacCatalyst)",
"value": "net7.0-android"
},
{
"condition": "(tfm == 'net8.0' && useAndroid && !useiOS && !useMacCatalyst)",
"value": "net8.0-android"
},
{
"condition": "(tfm == 'net7.0' && !useAndroid && useiOS && !useMacCatalyst)",
"value": "net7.0-ios"
},
{
"condition": "(tfm == 'net8.0' && !useAndroid && useiOS && !useMacCatalyst)",
"value": "net8.0-ios"
},
{
"condition": "(tfm == 'net7.0' && !useAndroid && !useiOS && useMacCatalyst)",
"value": "net7.0-maccatalyst"
},
{
"condition": "(tfm == 'net8.0' && !useAndroid && !useiOS && useMacCatalyst)",
"value": "net8.0-maccatalyst"
},
{
"condition": "(!useAndroid && !useiOS && !useMacCatalyst)",
"condition": "(platforms != android && platforms != ios && platforms != maccatalyst)",
"value": ""
}
]
Expand Down

0 comments on commit 8a0321e

Please sign in to comment.