Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions MultiTarget/UseUnoWinUI.ps1
Original file line number Diff line number Diff line change
@@ -1,56 +1,34 @@
Param (
[Parameter(HelpMessage = "The WinUI version to use when building an Uno head.", Mandatory = $true)]
[ValidateSet('2', '3')]
[string]$winUIMajorVersion,

[Parameter(HelpMessage = "Disables suppressing changes to the affected files in git, allowing changes to be committed.")]
[switch]$allowGitChanges = $false
[string]$winUIMajorVersion
)

# Suppress git warning "core.useBuiltinFSMonitor will be deprecated soon; use core.fsmonitor instead"
& git config advice.useCoreFSMonitorConfig false;

function SupressOrAllowChanges([string] $filePath) {
if ($allowGitChanges.IsPresent) {
git update-index --no-assume-unchanged $filePath
}
else {
git update-index --assume-unchanged $filePath
}
}

function ApplyWinUISwap([string] $filePath) {
SupressOrAllowChanges $filePath;

$fileContents = Get-Content -Path $filePath;

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

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

Set-Content -Force -Path $filePath -Value $fileContents;
Write-Output "Updated $(Resolve-Path -Relative $filePath)"
}

Write-Output "Switching to WinUI $winUIMajorVersion";
Write-Output "Switching Uno to WinUI $winUIMajorVersion";

ApplyWinUISwap $PSScriptRoot/../ProjectHeads/App.Head.Uno.props
ApplyWinUISwap $PSScriptRoot/PackageReferences/Uno.props
ApplyWinUISwap $PSScriptRoot/WinUI.TargetVersion.props

if ($allowGitChanges.IsPresent) {
Write-Warning "Changes to the default Uno package settings in Labs can now be committed.`r`nRun this command again without -allowGitChanges to disable committing further changes.";
}
else {
Write-Output "Changes to the default Uno package settings in Labs are now suppressed.`r`nTo switch branches, run `"git reset --hard`" with a clean working tree.";
}

Write-Output "Done, switched to WinUI $winUIMajorVersion"
Write-Output "Done. Please close and regenerate your solution. Do not commit these changes to the tooling repository."
9 changes: 4 additions & 5 deletions ProjectHeads/App.Head.Uno.UI.Dependencies.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<!-- Nuget package dependencies for all deployable Uno project heads that use WinUI 2 -->
<!-- Due to the quirks of non-sdk style projects, we cannot create a unified Dependencies.props for deployable head. -->
<Project>
<ItemGroup>
<!--<PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Markdown" Version="7.1.11" />-->
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.3.1-uno.2" />
<PackageReference Include="CommunityToolkit.Uwp.Converters" Version="8.0.0-beta.1" />
</ItemGroup>
<ItemGroup>
<!--<PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Markdown" Version="7.1.11" />-->
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.3.1-uno.2" />
</ItemGroup>
</Project>


9 changes: 4 additions & 5 deletions ProjectHeads/App.Head.Uno.WinUI.Dependencies.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<!-- Nuget package dependencies for all deployable Uno project heads that use WinUI 3 -->
<!-- Due to the quirks of non-sdk style projects, we cannot create a unified Dependencies.props for deployable head. -->
<Project>
<ItemGroup>
<!--<PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.100-dev.15.g12261e2626" />-->
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.3.1-uno.2" />
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.0.0-beta.1" />
</ItemGroup>
<ItemGroup>
<!--<PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.100-dev.15.g12261e2626" />-->
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.3.1-uno.2" />
</ItemGroup>
</Project>
22 changes: 13 additions & 9 deletions ProjectHeads/App.Head.Uno.props
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<Project>
<Import Project="$(MSBuildThisFileDirectory)\App.Head.props" />
<Import Project="$(MSBuildThisFileDirectory)\..\MultiTarget\PackageReferences\Uno.props" />
<Import Project="$(MSBuildThisFileDirectory)\..\MultiTarget\WinUI.Extra.props" />
<PropertyGroup>
<DependencyVariant>Uwp</DependencyVariant>
</PropertyGroup>

<!--
Import Uno dependencies for all deployable Uno-based Labs project heads.
This import must be inside THIS file to allow swapping between Uno.​UI and Uno.​WinUI via pwsh.
Changes to this file are suppressed by git when switching to avoid changing the default for all users.
-->
<Import Project="$(MSBuildThisFileDirectory)\App.Head.Uno.UI.Dependencies.props" />
<Import Project="$(MSBuildThisFileDirectory)\App.Head.props" />
<Import Project="$(MSBuildThisFileDirectory)\..\MultiTarget\PackageReferences\Uno.props" />
<Import Project="$(MSBuildThisFileDirectory)\..\MultiTarget\WinUI.Extra.props" />

<!--
Import Uno dependencies for all deployable Uno-based Labs project heads.
This import must be inside THIS file to allow swapping between Uno.​UI and Uno.​WinUI via pwsh.
Changes to this file are suppressed by git when switching to avoid changing the default for all users.
-->
<Import Project="$(MSBuildThisFileDirectory)\App.Head.Uno.UI.Dependencies.props" />
</Project>
11 changes: 5 additions & 6 deletions ProjectHeads/App.Head.Uwp.Dependencies.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!-- Nuget package dependencies for all deployable UWP project heads -->
<!-- Due to the quirks of non-sdk style projects, we cannot create a unified Dependencies.props for deployable head. -->
<Project>
<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Markdown" Version="7.1.2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.0.1" />
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
<PackageReference Include="CommunityToolkit.Uwp.Converters" Version="8.0.0-beta.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Markdown" Version="7.1.2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.0.1" />
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion ProjectHeads/App.Head.Uwp.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

<PropertyGroup>
<TargetFramework>$(UwpTargetFramework)</TargetFramework>
<DependencyVariant>Uwp</DependencyVariant>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)\App.Head.Uwp.Dependencies.props" />
<Import Project="$(MSBuildThisFileDirectory)\App.Head.props" />
<Import Project="$(MSBuildThisFileDirectory)\Head.Uwp.props" />
<Import Project="$(MSBuildThisFileDirectory)\App.Head.Uwp.Dependencies.props" />
</Project>
9 changes: 4 additions & 5 deletions ProjectHeads/App.Head.WinAppSdk.Dependencies.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<!-- Nuget package dependencies for all deployable UWP project heads -->
<!-- Due to the quirks of non-sdk style projects, we cannot create a unified Dependencies.props for deployable head. -->
<Project>
<ItemGroup>
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.0.0-beta.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions ProjectHeads/App.Head.WinAppSdk.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project>
<PropertyGroup>
<DependencyVariant>WinUI</DependencyVariant>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)\App.Head.props" />
<Import Project="$(MSBuildThisFileDirectory)\Head.WinAppSdk.props" />
<Import Project="$(MSBuildThisFileDirectory)\App.Head.WinAppSdk.Dependencies.props" />
Expand Down
16 changes: 15 additions & 1 deletion ProjectHeads/App.Head.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@
<SlnGenIsDeployable>true</SlnGenIsDeployable>
</PropertyGroup>

<!-- Sample App Toolkit Dependencies -->
<Choose>
<When Condition="'$(ToolkitConvertersSourceProject)' == ''">
<ItemGroup>
<PackageReference Include="CommunityToolkit.$(DependencyVariant).Converters" Version="8.0.0-beta.1"/>
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<ProjectReference Include="$(ToolkitConvertersSourceProject)"/>
</ItemGroup>
</Otherwise>
</Choose>

<!-- See https://github.com/CommunityToolkit/Labs-Windows/issues/142 -->
<ItemGroup Condition="'$(IsAllExperimentHead)' == 'true'">
<!-- These are also included in the Samples props file, but added here to workaround https://github.com/unoplatform/uno/issues/2502 -->
Expand Down Expand Up @@ -50,7 +64,7 @@
<ItemGroup Condition="'$(IsSingleExperimentHead)' == 'true' or '$(IsProjectTemplateHead)' == 'true'">
<!-- These are also included in the Samples props file, but added here to workaround https://github.com/unoplatform/uno/issues/2502 -->
<Content Include="$(MSBuildProjectDirectory)\..\..\samples\**\*.md" Exclude="$(MSBuildProjectDirectory)\..\..\samples\obj\**\*.md;$(MSBuildProjectDirectory)\..\..\samples\bin\**\*.md;$(MSBuildProjectDirectory)\..\..\**\SourceAssets\**\*.md" Link="SourceAssets/%(RecursiveDir)%(FileName)%(Extension)"/>
<Content Include="$(MSBuildProjectDirectory)\..\..\samples\**\*.png" Exclude="$(MSBuildProjectDirectory)\..\..\samples\obj\**\*.png;$(MSBuildProjectDirectory)\..\..\samples\bin\**\*.png;$(MSBuildProjectDirectory)\..\..\**\SourceAssets\**\*.png" Link="SourceAssets/%(RecursiveDir)%(FileName)%(Extension)"/>
<Content Include="$(MSBuildProjectDirectory)\..\..\samples\**\*.png" Exclude="$(MSBuildProjectDirectory)\..\..\samples\obj\**\*.png;$(MSBuildProjectDirectory)\..\..\samples\bin\**\*.png;$(MSBuildProjectDirectory)\..\..\**\SourceAssets\**\*.png" Link="SourceAssets/%(RecursiveDir)%(FileName)%(Extension)"/>
<Content Include="$(MSBuildProjectDirectory)\..\..\samples\**\*.xaml" Exclude="$(MSBuildProjectDirectory)\..\..\samples\obj\**\*.xaml;$(MSBuildProjectDirectory)\..\..\samples\bin\**\*.xaml;$(MSBuildProjectDirectory)\..\..\**\SourceAssets\**\*.xaml" Link="SourceAssets/%(RecursiveDir)%(FileName)%(Extension)"/>

<!-- Link/.dat is a workaround for https://github.com/unoplatform/uno/issues/8649 -->
Expand Down