Skip to content

Commit

Permalink
Accommodate WinUI 2/3 dependencies per-experiment (#139)
Browse files Browse the repository at this point in the history
* Added props files for WinUI 2 and WinUI 3 dependencies

* Fixed an issue where WinUI version had to be swapped for Uwp or WinAppSdk to get dependencies

* Fixed UWP TargetFramework check

* Update template/lab/src/Labs.WinUI.Dependencies.props

Co-authored-by: Michael Hawker MSFT (XAML Llama) <[email protected]>

* Fixed invalid WinAppSdk check

* Rename UseWinUI to WinUIMajorVersion

* Added note for NS2.0 dependencies

* Update labs/CanvasLayout/src/Dependencies.WinUI3.props

* Moved lab WinUI dependency data to existing Uno props file

Co-authored-by: Michael Hawker MSFT (XAML Llama) <[email protected]>
  • Loading branch information
Arlodotexe and michael-hawker authored Jun 6, 2022
1 parent 5203527 commit aba0670
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 5 deletions.
4 changes: 4 additions & 0 deletions common/Labs.Uno.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
<IsDroid Condition="'$(IsDroid)' == '' AND '$(TargetFramework)' == '$(AndroidLibTargetFramework)'">True</IsDroid>
<IsMacOS Condition="'$(IsMacOS)' == '' AND '$(TargetFramework)' == '$(MacOSLibTargetFramework)'">True</IsMacOS>
<IsiOS Condition="'$(IsiOS)' == '' AND '$(TargetFramework)' == '$(iOSLibTargetFramework)'">True</IsiOS>

<IsUwp Condition="'$(IsUwp)' == '' AND '$(TargetFramework)' == '$(UwpTargetFramework)'">True</IsUwp>
<IsWinAppSdk Condition="'$(IsWinAppSdk)' == '' AND '$(TargetFramework)' == '$(WinAppSdkTargetFramework)'">True</IsWinAppSdk>

<IsUno Condition="'$(IsWasm)' == 'true' OR '$(IsWpf)' == 'true' OR '$(IsGtk)' == 'true' OR '$(IsDroid)' == 'true' OR '$(IsMacOS)' == 'true' OR '$(IsiOS)' == 'true'">True</IsUno>

<DefineConstants Condition="'$(IsUno)' == 'true'">$(DefineConstants);</DefineConstants>

<PackageIdVariant>Uwp</PackageIdVariant>
<WinUIMajorVersion>2</WinUIMajorVersion>
</PropertyGroup>

<ItemGroup Condition="'$(IsUno)' == 'true'">
Expand Down
10 changes: 6 additions & 4 deletions common/Scripts/UseUnoWinUI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,27 @@ Param (
& git config advice.useCoreFSMonitorConfig false;

if ($allowGitChanges.IsPresent) {
Write-Warning "Changes to the default Uno package references in Labs can now be committed. Run this command again without the -allowGitChanges flag to disable committing further changes.";
Write-Warning "Changes to the default Uno package settings in Labs can now be committed. Run this command again without the -allowGitChanges flag to disable committing further changes.";
git update-index --no-assume-unchanged ../Labs.Uno.props
}
else {
Write-Output "Changes the default Uno package references in Labs are now suppressed. To switch branches, run git reset --hard with a clean working tree.";
Write-Output "Changes to the default Uno package settings in Labs are now suppressed. To switch branches, run git reset --hard with a clean working tree.";
git update-index --assume-unchanged ../Labs.Uno.props
}

$fileContents = Get-Content -Path ../Labs.Uno.props

if ($targets -eq "3") {
$fileContents = $fileContents -replace '<WinUIMajorVersion>2</WinUIMajorVersion>', '<WinUIMajorVersion>3</WinUIMajorVersion>';
$fileContents = $fileContents -replace '<PackageIdVariant>Uwp</PackageIdVariant>', '<PackageIdVariant>WinUI</PackageIdVariant>';
$fileContents = $fileContents -replace 'Uno.UI', 'Uno.WinUI';
$fileContents = $fileContents -replace 'Uwp', 'WinUI';
$fileContents = $fileContents -replace '\$\(DefineConstants\);', '$(DefineConstants);WINAPPSDK;';
}

if ($targets -eq "2") {
$fileContents = $fileContents -replace '<WinUIMajorVersion>3</WinUIMajorVersion>', '<WinUIMajorVersion>2</WinUIMajorVersion>';
$fileContents = $fileContents -replace '<PackageIdVariant>WinUI</PackageIdVariant>', '<PackageIdVariant>Uwp</PackageIdVariant>';
$fileContents = $fileContents -replace 'Uno.WinUI', 'Uno.UI';
$fileContents = $fileContents -replace 'WinUI', 'Uwp';
$fileContents = $fileContents -replace 'WINAPPSDK;', '';
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
<Import Project="$(RepositoryDirectory)common\Labs.MultiTarget.props" />
<Import Project="Dependencies.WinUI2.props" />
<Import Project="Dependencies.WinUI3.props" />

<PropertyGroup>
<RootNamespace>CommunityToolkit.Labs.WinUI.CanvasLayoutRns</RootNamespace>
Expand Down
20 changes: 20 additions & 0 deletions labs/CanvasLayout/src/Dependencies.WinUI2.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
HOW TO USE THIS FILE
WinUI 2 under UWP uses TargetFramework uap10.0.*
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
However, under Uno-powered platforms, both WinUI 2 and 3 share the same TargetFramework.
MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.
For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
For WinUI 2 / Uno packages, place the package references here.
-->
<Project>
<ItemGroup Condition="'$(IsUwp)' == 'True'">

</ItemGroup>
<ItemGroup Condition="'$(WinUIMajorVersion)' == '2' AND '$(IsUno)' == 'True'">

</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions labs/CanvasLayout/src/Dependencies.WinUI3.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
HOW TO USE THIS FILE
WinUI 2 under UWP uses TargetFramework uap10.0.*
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
However, under Uno-powered platforms, both WinUI 2 and 3 share the same TargetFramework.
MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.
For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
For WinUI 3 / Uno packages, place the package references here.
-->
<Project>
<ItemGroup Condition="'$(IsWinAppSdk)' == 'True'">

</ItemGroup>
<ItemGroup Condition="'$(WinUIMajorVersion)' == '3' AND '$(IsUno)' == 'True'">

</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
<Import Project="$(RepositoryDirectory)common\Labs.MultiTarget.props" />

<Import Project="Dependencies.WinUI2.props" />
<Import Project="Dependencies.WinUI3.props" />
<PropertyGroup>
<RootNamespace>CommunityToolkit.Labs.WinUI.SizerBaseRns</RootNamespace>
</PropertyGroup>
Expand Down
20 changes: 20 additions & 0 deletions labs/SizerBase/src/Dependencies.WinUI2.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
HOW TO USE THIS FILE
WinUI 2 under UWP uses TargetFramework uap10.0.*
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
However, under Uno-powered platforms, both WinUI 2 and 3 share the same TargetFramework.
MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.
For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
For WinUI 2 / Uno packages, place the package references here.
-->
<Project>
<ItemGroup Condition="'$(IsUwp)' == 'True'">

</ItemGroup>
<ItemGroup Condition="'$(WinUIMajorVersion)' == '2' AND '$(IsUno)' == 'True'">

</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions labs/SizerBase/src/Dependencies.WinUI3.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
HOW TO USE THIS FILE
WinUI 2 under UWP uses TargetFramework uap10.0.*
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
However, under Uno-powered platforms, both WinUI 2 and 3 share the same TargetFramework.
MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.
For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
For WinUI 3 / Uno packages, place the package references here.
-->
<Project>
<ItemGroup Condition="'$(IsWinAppSdk)' == 'True'">

</ItemGroup>
<ItemGroup Condition="'$(WinUIMajorVersion)' == '3' AND '$(IsUno)' == 'True'">

</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
<Import Project="$(RepositoryDirectory)common\Labs.MultiTarget.props" />
<Import Project="Dependencies.WinUI2.props" />
<Import Project="Dependencies.WinUI3.props" />

<PropertyGroup>
<RootNamespace>CommunityToolkit.Labs.WinUI.ProjectTemplateRns</RootNamespace>
Expand Down
20 changes: 20 additions & 0 deletions template/lab/src/Dependencies.WinUI2.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
HOW TO USE THIS FILE
WinUI 2 under UWP uses TargetFramework uap10.0.*
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
However, under Uno-powered platforms, both WinUI 2 and 3 share the same TargetFramework.
MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.
For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
For WinUI 2 / Uno packages, place the package references here.
-->
<Project>
<ItemGroup Condition="'$(IsUwp)' == 'True'">

</ItemGroup>
<ItemGroup Condition="'$(WinUIMajorVersion)' == '2' AND '$(IsUno)' == 'True'">

</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions template/lab/src/Dependencies.WinUI3.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
HOW TO USE THIS FILE
WinUI 2 under UWP uses TargetFramework uap10.0.*
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
However, under Uno-powered platforms, both WinUI 2 and 3 share the same TargetFramework.
MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.
For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
For WinUI 3 / Uno packages, place the package references here.
-->
<Project>
<ItemGroup Condition="'$(IsWinAppSdk)' == 'True'">

</ItemGroup>
<ItemGroup Condition="'$(WinUIMajorVersion)' == '3' AND '$(IsUno)' == 'True'">

</ItemGroup>
</Project>

0 comments on commit aba0670

Please sign in to comment.