Skip to content

Commit 93a54d7

Browse files
committed
Merge branch 'main' into niels9001/titlebar-improvements
2 parents 90d98dd + 9995251 commit 93a54d7

12 files changed

+96
-101
lines changed

MultiTarget/GenerateAllProjectReferences.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Param (
44

55
[Parameter(HelpMessage = "Only projects that support these targets will have references generated for use by deployable heads.")]
66
[string[]] $MultiTarget = @("uwp", "wasdk", "wpf", "wasm", "linuxgtk", "macos", "ios", "android", "netstandard")
7-
)
7+
)
88

99
$preWorkingDir = $pwd;
1010
Set-Location $PSScriptRoot;
@@ -17,13 +17,13 @@ New-Item -ItemType Directory -Force -Path $projectPropsOutputDir -ErrorAction Si
1717
foreach ($projectPath in Get-ChildItem -Directory -Path "$PSScriptRoot/../../components/*") {
1818
$srcPath = Resolve-Path "$($projectPath.FullName)\src";
1919
$srcProjectPath = Get-ChildItem -File "$srcPath\*.csproj";
20-
21-
$samplePath = Resolve-Path "$($projectPath.FullName)\samples";
22-
$sampleProjectPath = Get-ChildItem -File "$samplePath\*.csproj";
20+
$sampleProjectPath = Get-ChildItem -File "$($projectPath.FullName)\samples\*.csproj" -ErrorAction SilentlyContinue;
2321

2422
# Generate <ProjectReference>s for sample project
2523
# Use source project MultiTarget as first fallback.
26-
& $PSScriptRoot\GenerateMultiTargetAwareProjectReferenceProps.ps1 -projectPath $sampleProjectPath -outputPath "$projectPropsOutputDir/$($sampleProjectPath.BaseName).props" -MultiTarget $MultiTarget
24+
if ($null -ne $sampleProjectPath -and (Test-Path $sampleProjectPath)) {
25+
& $PSScriptRoot\GenerateMultiTargetAwareProjectReferenceProps.ps1 -projectPath $sampleProjectPath -outputPath "$projectPropsOutputDir/$($sampleProjectPath.BaseName).props" -MultiTarget $MultiTarget
26+
}
2727

2828
# Generate <ProjectReference>s for src project
2929
& $PSScriptRoot\GenerateMultiTargetAwareProjectReferenceProps.ps1 -projectPath $srcProjectPath -outputPath "$projectPropsOutputDir/$($srcProjectPath.BaseName).props" -MultiTarget $MultiTarget

MultiTarget/GenerateMultiTargetAwareProjectReferenceProps.ps1

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ Param (
88
[Parameter(HelpMessage = "The path to the template used to generate the props file.")]
99
[string]$templatePath = "$PSScriptRoot/MultiTargetAwareProjectReference.props.template",
1010

11-
[Parameter(HelpMessage = "The path to the props file that contains the default MultiTarget values.")]
12-
[string[]]$multiTargetFallbackPropsPath = @("$PSScriptRoot/Defaults.props"),
13-
1411
[Parameter(HelpMessage = "The placeholder text to replace when inserting the project file name into the template.")]
1512
[string]$projectFileNamePlaceholder = "[ProjectFileName]",
1613

@@ -33,15 +30,50 @@ Set-Location $preWorkingDir;
3330
# Insert csproj file name.
3431
$csprojFileName = [System.IO.Path]::GetFileName($relativeProjectPath);
3532
$templateContents = $templateContents -replace [regex]::escape($projectFileNamePlaceholder), $csprojFileName;
36-
$projectName = (Get-Item (Split-Path -Parent $projectPath)).Name;
3733

3834
# Insert project directory
3935
$projectDirectoryRelativeToRoot = [System.IO.Path]::GetDirectoryName($relativeProjectPath).TrimStart('.').TrimStart('\');
4036
$templateContents = $templateContents -replace [regex]::escape($projectRootPlaceholder), "$projectDirectoryRelativeToRoot";
4137

4238
# Load multitarget preferences for project
43-
$multiTargets = & $PSScriptRoot\GetMultiTargets.ps1 -ComponentName $projectName -ErrorAction Stop;
44-
39+
# Folder layout is expected to match the Community Toolkit.
40+
$projectName = (Get-Item (Split-Path -Parent (Split-Path -Parent $projectPath))).Name;
41+
$componentPath = "$PSScriptRoot/../../components/$projectName";
42+
43+
$srcPath = Resolve-Path "$componentPath\src";
44+
$samplePath = "$componentPath\samples";
45+
46+
# Uses the <MultiTarget> values from the source library project as the fallback for the sample project.
47+
# This behavior also implemented in TargetFramework evaluation.
48+
$multiTargetFallbackPropsPaths = @()
49+
50+
if($projectPath.ToLower().Contains('sample')) {
51+
$multiTargetFallbackPropsPaths += @("$samplePath/MultiTarget.props", "$srcPath/MultiTarget.props")
52+
} else {
53+
$multiTargetFallbackPropsPaths += @("$srcPath/MultiTarget.props")
54+
}
55+
56+
$multiTargetFallbackPropsPaths += @("$PSScriptRoot/Defaults.props")
57+
58+
# Load first available default
59+
$fileContents = "";
60+
foreach ($fallbackPath in $multiTargetFallbackPropsPaths) {
61+
if (Test-Path $fallbackPath) {
62+
$fileContents = Get-Content $fallbackPath -ErrorAction Stop;
63+
break;
64+
}
65+
}
66+
67+
# Parse file contents
68+
$regex = Select-String -Pattern '<MultiTarget>(.+?)<\/MultiTarget>' -InputObject $fileContents;
69+
70+
if ($null -eq $regex -or $null -eq $regex.Matches -or $null -eq $regex.Matches.Groups -or $regex.Matches.Groups.Length -lt 2) {
71+
Write-Error "Couldn't get MultiTarget property from $path";
72+
exit(-1);
73+
}
74+
75+
$multiTargets = $regex.Matches.Groups[1].Value;
76+
4577
$templateContents = $templateContents -replace [regex]::escape("[IntendedTargets]"), $multiTargets;
4678
$multiTargets = $multiTargets.Split(';');
4779

MultiTarget/GetMultiTargets.ps1

Lines changed: 0 additions & 58 deletions
This file was deleted.

MultiTarget/UseUnoWinUI.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ function ApplyWinUISwap([string] $filePath) {
2727
if ($winUIMajorVersion -eq "3") {
2828
$fileContents = $fileContents -replace '<WinUIMajorVersion>2</WinUIMajorVersion>', '<WinUIMajorVersion>3</WinUIMajorVersion>';
2929
$fileContents = $fileContents -replace '<PackageIdVariant>Uwp</PackageIdVariant>', '<PackageIdVariant>WinUI</PackageIdVariant>';
30+
$fileContents = $fileContents -replace '<DependencyVariant>Uwp</DependencyVariant>', '<DependencyVariant>WinUI</DependencyVariant>';
3031
$fileContents = $fileContents -replace 'Uno.UI', 'Uno.WinUI';
3132
}
3233

3334
if ($winUIMajorVersion -eq "2") {
3435
$fileContents = $fileContents -replace '<WinUIMajorVersion>3</WinUIMajorVersion>', '<WinUIMajorVersion>2</WinUIMajorVersion>';
3536
$fileContents = $fileContents -replace '<PackageIdVariant>WinUI</PackageIdVariant>', '<PackageIdVariant>Uwp</PackageIdVariant>';
37+
$fileContents = $fileContents -replace '<DependencyVariant>WinUI</DependencyVariant>', '<DependencyVariant>Uwp</DependencyVariant>';
3638
$fileContents = $fileContents -replace 'Uno.WinUI', 'Uno.UI';
3739
}
3840

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<!-- Nuget package dependencies for all deployable Uno project heads that use WinUI 2 -->
22
<!-- Due to the quirks of non-sdk style projects, we cannot create a unified Dependencies.props for deployable head. -->
33
<Project>
4-
<ItemGroup>
5-
<!--<PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Markdown" Version="7.1.11" />-->
6-
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.3.1-uno.2" />
7-
<PackageReference Include="CommunityToolkit.Uwp.Converters" Version="8.0.0-beta.1" />
8-
</ItemGroup>
4+
<ItemGroup>
5+
<!--<PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Markdown" Version="7.1.11" />-->
6+
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.3.1-uno.2" />
7+
</ItemGroup>
98
</Project>
109

1110

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<!-- Nuget package dependencies for all deployable Uno project heads that use WinUI 3 -->
22
<!-- Due to the quirks of non-sdk style projects, we cannot create a unified Dependencies.props for deployable head. -->
33
<Project>
4-
<ItemGroup>
5-
<!--<PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.100-dev.15.g12261e2626" />-->
6-
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.3.1-uno.2" />
7-
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.0.0-beta.1" />
8-
</ItemGroup>
4+
<ItemGroup>
5+
<!--<PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.100-dev.15.g12261e2626" />-->
6+
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.3.1-uno.2" />
7+
</ItemGroup>
98
</Project>

ProjectHeads/App.Head.Uno.props

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<Project>
2-
<Import Project="$(MSBuildThisFileDirectory)\App.Head.props" />
3-
<Import Project="$(MSBuildThisFileDirectory)\..\MultiTarget\PackageReferences\Uno.props" />
4-
<Import Project="$(MSBuildThisFileDirectory)\..\MultiTarget\WinUI.Extra.props" />
2+
<PropertyGroup>
3+
<DependencyVariant>Uwp</DependencyVariant>
4+
</PropertyGroup>
55

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

ProjectHeads/App.Head.Uwp.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
<PropertyGroup>
55
<TargetFramework>$(UwpTargetFramework)</TargetFramework>
6+
<DependencyVariant>Uwp</DependencyVariant>
67
</PropertyGroup>
78

8-
<Import Project="$(MSBuildThisFileDirectory)\App.Head.Uwp.Dependencies.props" />
99
<Import Project="$(MSBuildThisFileDirectory)\App.Head.props" />
1010
<Import Project="$(MSBuildThisFileDirectory)\Head.Uwp.props" />
11+
<Import Project="$(MSBuildThisFileDirectory)\App.Head.Uwp.Dependencies.props" />
1112
</Project>
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<!-- Nuget package dependencies for all deployable UWP project heads -->
22
<!-- Due to the quirks of non-sdk style projects, we cannot create a unified Dependencies.props for deployable head. -->
33
<Project>
4-
<ItemGroup>
5-
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.2" />
6-
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
7-
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.0.0-beta.1" />
8-
</ItemGroup>
4+
<ItemGroup>
5+
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.2" />
6+
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
7+
</ItemGroup>
98
</Project>

0 commit comments

Comments
 (0)