Skip to content

Commit 2db3bdd

Browse files
committed
Upgrade projects to Uno.Sdk
1 parent 795e381 commit 2db3bdd

37 files changed

Lines changed: 640 additions & 11 deletions

GenerateAllSolution.ps1

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ Param (
5454
[string[]]$ExcludeComponents,
5555

5656
[switch]$UseDiagnostics = $false,
57-
58-
[bool]$Launch = $true
57+
58+
[bool]$Launch = $true,
59+
60+
[switch]$IncludeUnoSdkHead = $false
5961
)
6062

6163
if ($MultiTargets.Contains('all')) {
@@ -147,11 +149,13 @@ foreach ($componentName in $Components) {
147149

148150
# Deployable sample gallery heads
149151
# Only include heads for requested MultiTargets if components were included that use them.
150-
# ===
151-
# TODO: this handles separate project heads, but won't directly handle the unified Skia head from Uno.
152-
# Once we have that, just do a transform on the csproj filename inside this loop to decide the same csproj for those separate MultiTargets.
153-
# ===
154152
foreach ($multitarget in $allUsedMultiTargetPrefs) {
153+
# The Uno.Sdk head replaces the old per-platform Wasm head
154+
if ($multitarget -eq 'wasm') {
155+
# wasm library multi-targeting still works, but head is now Uno.Sdk-based
156+
continue
157+
}
158+
155159
# capitalize first letter, avoid case sensitivity issues on linux
156160
$csprojFileNamePartForMultiTarget = $multitarget.substring(0,1).ToUpper() + $multitarget.Substring(1).ToLower()
157161

@@ -165,6 +169,16 @@ foreach ($multitarget in $allUsedMultiTargetPrefs) {
165169
}
166170
}
167171

172+
# Add Uno.Sdk head if requested
173+
if ($IncludeUnoSdkHead) {
174+
$unoHeadPath = ".\tooling\ProjectHeads\AllComponents\Uno\CommunityToolkit.App.Uno.csproj"
175+
if (Test-Path $unoHeadPath) {
176+
[void]$projects.Add($unoHeadPath)
177+
} else {
178+
Write-Warning "Uno.Sdk head project not found at $unoHeadPath."
179+
}
180+
}
181+
168182
if ($UseDiagnostics.IsPresent)
169183
{
170184
$sdkoptions = "-d"

GenerateSingleSolution.ps1

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ Param (
4949
[string]$componentPath,
5050

5151
[Parameter(HelpMessage = "Add extra diagnostic output to slngen generator.")]
52-
[switch]$UseDiagnostics = $false
52+
[switch]$UseDiagnostics = $false,
53+
54+
[switch]$IncludeUnoSdkHead = $false
5355
)
5456

5557
if ($null -ne $Env:Path -and $Env:Path.ToLower().Contains("msbuild") -eq $false) {
@@ -179,9 +181,13 @@ Write-Output "Generating solution for $componentName in $generatedSolutionFilePa
179181

180182
# All heads are included by default since they reside in the same folder as the component.
181183
# Remove any heads that are not required for the solution.
182-
# TODO: this handles separate project heads, but won't directly handle the unified Skia head from Uno.
183-
# Once we have that, just do a transform on the csproj filename inside this loop to decide the same csproj for those separate MultiTargets.
184184
foreach ($multitarget in $MultiTargets) {
185+
# The Uno.Sdk head replaces the old per-platform Wasm head
186+
if ($multitarget -eq 'wasm') {
187+
# wasm library multi-targeting still works, but head is now Uno.Sdk-based
188+
continue
189+
}
190+
185191
# capitalize first letter, avoid case sensitivity issues on linux
186192
$csprojFileNamePartForMultiTarget = $multitarget.substring(0,1).ToUpper() + $multitarget.Substring(1).ToLower()
187193

@@ -199,6 +205,18 @@ foreach ($multitarget in $MultiTargets) {
199205
}
200206
}
201207

208+
# Add Uno.Sdk head if requested
209+
if ($IncludeUnoSdkHead) {
210+
$unoHeadPath = "$outputHeadsDir\Uno\*Uno.csproj"
211+
if (Test-Path $unoHeadPath) {
212+
foreach ($foundItem in Get-ChildItem $unoHeadPath) {
213+
$projects = $projects + $foundItem.FullName
214+
}
215+
} else {
216+
Write-Warning "Uno.Sdk head project not found at $unoHeadPath."
217+
}
218+
}
219+
202220
# Include common dependencies required for solution to build
203221
$projects = $projects + "$PSScriptRoot\CommunityToolkit.App.Shared\**\*.*proj"
204222
$projects = $projects + "$PSScriptRoot\CommunityToolkit.Tests.Shared\**\*.*proj"

GenerateVSCodeLaunchConfig.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ function CreateVsCodeLaunchConfigJson {
2020
`"/p:UnoSourceGeneratorUseGenerationHost=true`",
2121
`"/p:UnoSourceGeneratorUseGenerationController=false`",
2222
`"/p:UnoRemoteControlPort=443`",
23-
`"--project=`$`{workspaceFolder`}/components/$projectName/heads/Wasm/$projectName.Wasm.csproj`"
23+
`"--project=`$`{workspaceFolder`}/components/$projectName/heads/Uno/$projectName.Uno.csproj`"
2424
],
2525
`"presentation`": {
2626
`"group`": `"2`"
2727
},
28-
`"cwd`": `"`$`{workspaceFolder`}/components/$projectName/heads/Wasm`"
28+
`"cwd`": `"`$`{workspaceFolder`}/components/$projectName/heads/Uno`"
2929
}";
3030
}
3131

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<Project Sdk="Uno.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFrameworks>net10.0-desktop;net10.0-browserwasm;net10.0-android;net10.0-ios;net10.0-maccatalyst</TargetFrameworks>
5+
6+
<UnoFeatures>
7+
SkiaRenderer;
8+
</UnoFeatures>
9+
10+
<!-- Head project, not a package -->
11+
<IsPackable>false</IsPackable>
12+
<RootNamespace>CommunityToolkit.App.Uno</RootNamespace>
13+
14+
<!-- Platform flags for Generated/*.props project reference conditions -->
15+
<IsDeployableHead>true</IsDeployableHead>
16+
<IsUno>true</IsUno>
17+
<IsWasm>true</IsWasm>
18+
<HasWinUI>true</HasWinUI>
19+
<WinUIMajorVersion>3</WinUIMajorVersion>
20+
<IsAllExperimentHead>true</IsAllExperimentHead>
21+
<DependencyVariant>WinUI</DependencyVariant>
22+
23+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
24+
25+
<!-- Disable Uno.Sdk default Page/XAML auto-include — shared .projitems handles this -->
26+
<EnableDefaultUnoItems>false</EnableDefaultUnoItems>
27+
28+
<!-- Shared code compatibility constants -->
29+
<DefineConstants>$(DefineConstants);WINUI3</DefineConstants>
30+
</PropertyGroup>
31+
32+
<!-- Auto-generated project references (same as old Wasm head) -->
33+
<Import Project="$(ToolingDirectory)\MultiTarget\Generated\*.Samples.props" />
34+
<Import Project="$(ToolingDirectory)\MultiTarget\Generated\*.Source.props" />
35+
36+
<!-- Shared app code -->
37+
<Import Project="$(ToolingDirectory)\CommunityToolkit.App.Shared\CommunityToolkit.App.Shared.projitems" Label="Shared" />
38+
<Import Project="$(ToolingDirectory)\ProjectHeads\Targets\AddMultiTargetCompatibleSampleDocs.targets" />
39+
40+
<!-- Head dependencies (from App.Head.props) -->
41+
<ItemGroup>
42+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
43+
<PackageReference Include="Markdig" Version="0.38.0" />
44+
</ItemGroup>
45+
46+
<!-- Source generators -->
47+
<ItemGroup>
48+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" PrivateAssets="all" />
49+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" PrivateAssets="all" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<ProjectReference Include="$(ToolingDirectory)\CommunityToolkit.Tooling.SampleGen\CommunityToolkit.Tooling.SampleGen.csproj"
53+
OutputItemType="Analyzer" ReferenceOutputAssembly="true" />
54+
</ItemGroup>
55+
56+
<!-- Toolkit gallery dependencies (from App.Head.props) -->
57+
<ItemGroup>
58+
<PackageReference Include="CommunityToolkit.WinUI.Converters" Version="8.2.250402" />
59+
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.2.250402" />
60+
<PackageReference Include="CommunityToolkit.WinUI.Extensions" Version="8.2.250402" />
61+
<PackageReference Include="CommunityToolkit.WinUI.Triggers" Version="8.2.250402" />
62+
</ItemGroup>
63+
64+
<!-- Uno app dependencies (from App.Head.Uno.WinUI.Dependencies.props) -->
65+
<ItemGroup>
66+
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.Interactivity.WinUI" Version="3.0.3" />
67+
<PackageReference Include="Uno.WinUI.Lottie" Version="6.0.465" />
68+
</ItemGroup>
69+
70+
<!-- Sample doc content inclusion (from App.Head.props) -->
71+
<ItemGroup>
72+
<Content Include="$(RepositoryDirectory)components\**\samples\**\*.md"
73+
Exclude="$(RepositoryDirectory)**\**\samples\obj\**\*.md;$(RepositoryDirectory)**\**\samples\bin\**\*.md;$(RepositoryDirectory)**\SourceAssets\**\*.md">
74+
<Link>SourceAssets/%(RecursiveDir)%(FileName)%(Extension)</Link>
75+
</Content>
76+
<Content Include="$(RepositoryDirectory)components\**\samples\**\*.xaml"
77+
Exclude="$(RepositoryDirectory)**\**\samples\obj\**\*.xaml;$(RepositoryDirectory)**\**\samples\bin\**\*.xaml;$(RepositoryDirectory)**\SourceAssets\**\*.xaml">
78+
<Link>SourceAssets/%(RecursiveDir)%(FileName)%(Extension)</Link>
79+
</Content>
80+
<Content Include="$(RepositoryDirectory)components\**\samples\**\*.cs"
81+
Exclude="$(RepositoryDirectory)**\**\samples\obj\**\*.cs;$(RepositoryDirectory)**\**\samples\bin\**\*.cs">
82+
<Link>SourceAssets/%(RecursiveDir)%(FileName)%(Extension).dat</Link>
83+
</Content>
84+
<AdditionalFiles Include="$(RepositoryDirectory)components\**\src\**\*.csproj" />
85+
</ItemGroup>
86+
87+
<!-- Uno head suppression (from App.Head.Uno.props) -->
88+
<PropertyGroup Condition="'$(IsUno)' == 'true'">
89+
<NoWarn>$(NoWarn);IL2026;Uno0006</NoWarn>
90+
</PropertyGroup>
91+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="35" />
4+
<application android:label="CommunityToolkit" />
5+
</manifest>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Any raw assets you want to be deployed with your application can be placed in this
2+
directory (and child directories). Deployment of the asset to your application is done
3+
using the IDE or by using the following MSBuild property in your .csproj:
4+
5+
<AndroidAsset Include="Assets\filename.ext" />
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Android.App;
2+
using Android.Runtime;
3+
4+
namespace CommunityToolkit.App.Uno;
5+
6+
[global::Android.App.ApplicationAttribute(
7+
Label = "@string/ApplicationName",
8+
Icon = "@mipmap/iconapp",
9+
LargeHeap = true,
10+
HardwareAccelerated = true,
11+
Theme = "@style/AppTheme"
12+
)]
13+
public class Application : Microsoft.UI.Xaml.NativeApplication
14+
{
15+
public Application(IntPtr javaReference, JniHandleOwnership transfer)
16+
: base(() => new CommunityToolkit.App.Shared.App(), javaReference, transfer)
17+
{
18+
}
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
using Android.Views;
5+
using Android.Widget;
6+
7+
namespace CommunityToolkit.App.Uno;
8+
9+
[Activity(
10+
MainLauncher = true,
11+
ConfigurationChanges = global::Uno.UI.ActivityHelper.AllConfigChanges,
12+
WindowSoftInputMode = SoftInput.AdjustNothing | SoftInput.StateHidden
13+
)]
14+
public class MainActivity : Microsoft.UI.Xaml.ApplicationActivity
15+
{
16+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="ApplicationName">CommunityToolkit</string>
4+
</resources>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<resources>
3+
<style name="AppTheme" parent="Theme.AppCompat.Light">
4+
</style>
5+
6+
<style name="AppTheme.Starting" parent="Theme.SplashScreen">
7+
</style>
8+
</resources>

0 commit comments

Comments
 (0)