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
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copilot instructions: Windows Community Toolkit

Stable WinUI components (`components/<Name>/{src,samples,tests}`) shipped as `CommunityToolkit.Uwp.*` (UWP, WinUI 2) and `CommunityToolkit.WinUI.*` (Windows App SDK and Uno, WinUI 3) NuGet packages. The build system, sample/test heads, generators and scripts live in the `tooling/` git submodule; this repo is the consumer layout they are designed for, so tooling scripts run in place here. New features start in Windows Community Toolkit Labs (`CommunityToolkit/Labs-Windows`); this repo takes fixes and components migrated from Labs (the PR template asks for a link to the migration approval).
Stable WinUI components (`components/<Name>/{src,samples,tests}`) shipped as `CommunityToolkit.Uwp.*` (UWP, WinUI 2), `CommunityToolkit.WinUI.*` (Windows App SDK, WinUI 3) and `CommunityToolkit.Uno.*` (Uno Platform) NuGet packages: each UI framework has its own set, packed separately, and a package never mixes target frameworks of different UI frameworks. The build system, sample/test heads, generators and scripts live in the `tooling/` git submodule; this repo is the consumer layout they are designed for, so tooling scripts run in place here. New features start in Windows Community Toolkit Labs (`CommunityToolkit/Labs-Windows`); this repo takes fixes and components migrated from Labs (the PR template asks for a link to the migration approval).

## Tooling docs (not auto-loaded)
Copilot only loads `.github` from this repo root, so read these explicitly:
Expand Down
2 changes: 1 addition & 1 deletion .github/instructions/components.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ applyTo: "components/**,catalog/**,tools/**"
- Prefer `$(Toolkit<Name>SourceProject)` from the root `Directory.Build.props` over relative paths for sibling component references (add the property there if it is missing).
- Component projects reference siblings unconditionally, so a referenced component must be buildable on every MultiTarget the referencing one builds for (e.g. a component that builds for Uno cannot depend on a `uwp;wasdk`-only one).
- Converters, SettingsControls, Extensions and Triggers are project-referenced by every sample app head (Extensions also by every test head), and `tooling/` code consumes their public API: a break or API change in one of them breaks every head, and the tooling side cannot be fixed from here.
- The sample index takes `nugetPackage` from the `src` csproj *file name*, which is the WinUI-variant package id (`CommunityToolkit.WinUI...`; the UWP variant swaps the variant segment). The tooling default `PackageId` has no `.Controls`, so a control must set `PackageId` to `$(PackageIdPrefix).$(PackageIdVariant).Controls.$(ToolkitComponentName)` and name its csproj to match; the `ctk-component` template does not do this. Set it *after* the `ToolkitComponent.SourceProject.props` import, which is what defines `PackageIdVariant`.
- The sample index takes `nugetPackage` from the `src` csproj *file name*, which is the WinUI-variant package id (`CommunityToolkit.WinUI...`; the Uwp and Uno variants swap the variant segment, and a `uwp;wasdk`-only component has no Uno package). The tooling default `PackageId` has no `.Controls`, so a control must set `PackageId` to `$(PackageIdPrefix).$(PackageIdVariant).Controls.$(ToolkitComponentName)` and name its csproj to match; the `ctk-component` template does not do this. Set it *after* the `ToolkitComponent.SourceProject.props` import, which is what defines `PackageIdVariant`. Never hard-code a variant in a `PackageId`: each UI framework is packed in its own leg, and a fixed id would be produced by all of them.

## Sample index (`catalog/toolkit-samples.json`)
`catalog/README.md` describes the file and the `generate`/`check` commands. Easy to miss:
Expand Down
6 changes: 3 additions & 3 deletions .github/skills/validate-component-changes/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Mirrors `.github/workflows/build.yml`; run from the repo root on Windows. Read `

## Prerequisites
- `msbuild.exe` from Visual Studio on `PATH` (Developer shell, or prepend `<VS>\MSBuild\Current\Bin\amd64`); otherwise `GenerateSingleSolution.ps1` waits for a keypress. `vstest.console.exe` lives in `<VS>\Common7\IDE\CommonExtensions\Microsoft\TestWindow`.
- `dotnet tool restore` once. Build requirements are in `ReadMe.md` and `tooling/ReadMe.md`; CI runs `uno-check` for every leg except `wasdk`, `wpf` and `linuxgtk`.
- `dotnet tool restore` once. Build requirements are in `ReadMe.md` and `tooling/ReadMe.md`; CI runs `uno-check` only for the `macos`, `ios` and `android` build legs and the `uno` package leg (the other Uno legs, `wasm`, `wpf` and `linuxgtk`, compile to a plain `net10.0` library and need no workload).
- If nuget.org is unreachable, restore fails; revert any local feed override in `nuget.config` before committing.

## 1. Fast loop: one component
Expand All @@ -28,9 +28,9 @@ The WinAppSdk test host needs the .NET runtime matching the head's TFM; if it is
## 2. Release gate on source projects
```powershell
New-Item -ItemType Directory $env:TEMP\nupkgs -Force | Out-Null
./tooling/Build-Toolkit-Components.ps1 -Components <Name> -MultiTargets wasdk -WinUIMajorVersion 3 -Release -NupkgOutput $env:TEMP\nupkgs
./tooling/Build-Toolkit-Components.ps1 -Components <Name> -UIFramework winui -Release -NupkgOutput $env:TEMP\nupkgs
```
Builds each `src` project (and its dependencies) directly in Release; packs only because `-NupkgOutput` is given, and that folder must already exist. A component that does not support the MultiTarget is skipped with a warning and exit code 0. CI's package job uses `-MultiTargets all` per WinUI version.
Builds each `src` project (and its dependencies) directly in Release; packs only because `-NupkgOutput` is given, and that folder must already exist. A component that does not support the MultiTarget is skipped with a warning and exit code 0. Each UI framework has its own packages (`uwp`: `CommunityToolkit.Uwp.*`, `winui`: `CommunityToolkit.WinUI.*`, `uno`: `CommunityToolkit.Uno.*`) and packing refuses to mix them, so `-MultiTargets all -WinUIMajorVersion 3` throws: CI's package job runs `-UIFramework <uwp|winui|uno>` once per leg (`-MultiTargets` then defaults to `all`). `uwp` and `winui` build the same TFM into the same folders, so clean (step 5) between them. The mobile Uno TFMs (`macos`, `ios`, `android`) need workloads: pack `uno` with `-ExcludeMultiTargets macos,ios,android` unless `uno-check` has installed them.

## 3. CI build legs (all components)
One leg per `build.yml` matrix entry (`uwp` with WinUI 2; the rest with WinUI 3):
Expand Down
58 changes: 34 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- name: Run sample index tests
run: dotnet test tools/SampleIndexExporter.Tests

# Build both the UWP/WinUI2 and the WindowsAppSDK + Uno.WinUI/WinUI3 versions of our packages using a matrix
# Build every MultiTarget (UWP/WinUI 2, Windows App SDK/WinUI 3 and the Uno Platform ones) using a matrix
build:
needs: [Xaml-Style-Check]
runs-on: windows-2025-large
Expand Down Expand Up @@ -137,14 +137,16 @@ jobs:
Invoke-WebRequest -Uri https://download.sysinternals.com/files/Procdump.zip -OutFile Procdump.zip
Expand-Archive -Path Procdump.zip -DestinationPath ${{ env.PROCDUMP_PATH }}

# Restore Tools from Manifest list in the Repository
# The dotnet tools are only needed for uno-check, and only the mobile Uno targets need workloads
# (wasm, wpf and linuxgtk compile to a plain net10.0 library, and uwp and wasdk need none either).
- name: Restore dotnet tools
if: ${{ matrix.multitarget == 'macos' || matrix.multitarget == 'ios' || matrix.multitarget == 'android' }}
run: dotnet tool restore

# uno-check ignores global.json and installs workloads with the newest SDK on the machine.
# Remove SDKs newer than the global.json one so workloads match the SDK we build with.
- name: Remove .NET SDKs newer than global.json
if: ${{ matrix.multitarget != 'wasdk' && matrix.multitarget != 'linuxgtk' && matrix.multitarget != 'wpf' }}
if: ${{ matrix.multitarget == 'macos' || matrix.multitarget == 'ios' || matrix.multitarget == 'android' }}
shell: pwsh
run: |
$selected = [System.Management.Automation.SemanticVersion](dotnet --version)
Expand All @@ -154,7 +156,7 @@ jobs:
dotnet --list-sdks

- name: Run Uno Check to Install Dependencies
if: ${{ matrix.multitarget != 'wasdk' && matrix.multitarget != 'linuxgtk' && matrix.multitarget != 'wpf' }}
if: ${{ matrix.multitarget == 'macos' || matrix.multitarget == 'ios' || matrix.multitarget == 'android' }}
run: >
dotnet tool run uno-check
--ci
Expand Down Expand Up @@ -187,11 +189,14 @@ jobs:
/v:${{ env.MSBUILD_VERBOSITY }}
CommunityToolkit.AllComponents.slnx

# Run tests
# Run tests (only the uwp and wasdk legs run tests)
- name: Setup VSTest Path
if: ${{ matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk' }}
uses: darenm/setup-vstest@3a16d909a1f3bbc65b52f8270d475d905e7d3e44

# The generator tests don't depend on the MultiTarget, so they only run in one leg
- name: Run SourceGenerators tests
if: ${{ matrix.multitarget == 'wasdk' }}
id: test-generator
run: vstest.console.exe ./tooling/CommunityToolkit.Tooling.SampleGen.Tests/bin/Release/net10.0/CommunityToolkit.Tooling.SampleGen.Tests.dll /logger:"trx;LogFileName=SourceGenerators.trx"

Expand Down Expand Up @@ -248,7 +253,8 @@ jobs:
strategy:
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them all to run to completion.
matrix:
winui: [2, 3]
# Each UI framework has its own set of packages: uwp (WinUI 2), winui (Windows App SDK, WinUI 3) and uno (Uno Platform)
ui: [uwp, winui, uno]

env:
VERSION_PROPERTY: ${{ github.ref == 'refs/heads/main' && format('build.{0}', github.run_number) || format('pull-{0}.{1}', github.event.number, github.run_number) }}
Expand Down Expand Up @@ -283,12 +289,13 @@ jobs:
run: |
echo "VERSION_DATE=$(git log -1 --format=%cd --date=format:%y%m%d)" >> $env:GITHUB_ENV

# uno-check is only needed to build the mobile Uno targets (see the matching steps in the build job)
- name: Restore dotnet tools
if: ${{ matrix.ui == 'uno' }}
run: dotnet tool restore

# See the matching step in the build job.
- name: Remove .NET SDKs newer than global.json
if: ${{ matrix.winui == '3' }}
if: ${{ matrix.ui == 'uno' }}
shell: pwsh
run: |
$selected = [System.Management.Automation.SemanticVersion](dotnet --version)
Expand All @@ -298,10 +305,13 @@ jobs:
dotnet --list-sdks

- name: Run Uno Check to Install Dependencies
if: ${{ matrix.winui == '3' }}
if: ${{ matrix.ui == 'uno' }}
run: >
dotnet tool run uno-check
--ci
--target android
--target ios
--target macos
--fix
--non-interactive
--skip wsl
Expand All @@ -315,9 +325,9 @@ jobs:
with:
vs-version: '[18.0,)'

# Build and pack component nupkg (WinUI 2 only builds uwp, WinUI 3 builds wasdk and all Uno targets)
# Build and pack component nupkg (a package can't mix UI frameworks, so each leg packs the MultiTargets of one: uwp, wasdk, or all the Uno ones)
- name: Build and pack component packages
run: ./tooling/Build-Toolkit-Components.ps1 -MultiTargets all -WinUIMajorVersion ${{ matrix.winui }} -DateForVersion ${{ env.VERSION_DATE }} ${{ env.VERSION_PROPERTY != '' && format('-PreviewVersion "{0}"', env.VERSION_PROPERTY) || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-EnableBinlogs' || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-Verbose' || '' }} -BinlogOutput ./ -NupkgOutput ./ -Release
run: ./tooling/Build-Toolkit-Components.ps1 -UIFramework ${{ matrix.ui }} -DateForVersion ${{ env.VERSION_DATE }} ${{ env.VERSION_PROPERTY != '' && format('-PreviewVersion "{0}"', env.VERSION_PROPERTY) || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-EnableBinlogs' || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-Verbose' || '' }} -BinlogOutput ./ -NupkgOutput ./ -Release

# Push Pull Request Packages to our DevOps Artifacts Feed (see nuget.config)
- name: Push Pull Request Packages (if not fork)
Expand All @@ -332,7 +342,7 @@ jobs:
uses: actions/upload-artifact@v4
if: ${{ env.IS_PR == 'false' }}
with:
name: nuget-list-${{ matrix.winui }}
name: nuget-list-${{ matrix.ui }}
if-no-files-found: error
path: |
${{ github.workspace }}/.github/workflows/SignClientFileList.txt
Expand All @@ -342,7 +352,7 @@ jobs:
uses: actions/upload-artifact@v4
if: ${{ env.IS_PR == 'false' || github.event.pull_request.head.repo.full_name != github.repository }}
with:
name: nuget-packages-winui${{ matrix.winui }}
name: nuget-packages-${{ matrix.ui }}
if-no-files-found: error
path: |
./*.nupkg
Expand All @@ -351,7 +361,7 @@ jobs:
uses: actions/upload-artifact@v4
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
with:
name: build-logs-winui${{ matrix.winui }}
name: build-logs-${{ matrix.ui }}
path: ./*.*log

sign:
Expand All @@ -362,9 +372,9 @@ jobs:
id-token: write # Required for requesting the JWT

strategy:
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them both to run to completion.
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them all to run to completion.
matrix:
winui: [2, 3]
ui: [uwp, winui, uno]

steps:
- name: Install .NET SDK
Expand All @@ -375,13 +385,13 @@ jobs:
- name: Download Package List
uses: actions/download-artifact@v4
with:
name: nuget-list-${{ matrix.winui }}
name: nuget-list-${{ matrix.ui }}
path: ./

- name: Download built packages for WinUI ${{ matrix.winui }}
- name: Download built ${{ matrix.ui }} packages
uses: actions/download-artifact@v4
with:
name: nuget-packages-winui${{ matrix.winui }}
name: nuget-packages-${{ matrix.ui }}
path: ./packages

- name: Install Signing Tool
Expand Down Expand Up @@ -415,7 +425,7 @@ jobs:
uses: actions/upload-artifact@v4
if: ${{ env.IS_RELEASE == 'true' }}
with:
name: signed-nuget-packages-${{ matrix.winui }}
name: signed-nuget-packages-${{ matrix.ui }}
if-no-files-found: error
path: |
${{ github.workspace }}/packages/**/*.nupkg
Expand All @@ -430,20 +440,20 @@ jobs:
id-token: write # Required for NuGet trusted publishing (OIDC)

strategy:
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them both to run to completion.
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them all to run to completion.
matrix:
winui: [2, 3]
ui: [uwp, winui, uno]

steps:
- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Download signed packages for WinUI ${{ matrix.winui }}
- name: Download signed ${{ matrix.ui }} packages
uses: actions/download-artifact@v4
with:
name: signed-nuget-packages-${{ matrix.winui }}
name: signed-nuget-packages-${{ matrix.ui }}
path: ./packages

- name: NuGet login (OIDC to temporary API key)
Expand Down
6 changes: 4 additions & 2 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project>
<PropertyGroup>
<CommonTags>$(CommonTags);UWP;WinUI;Platform;WindowsAppSDK;WASDK;WinAppSDK;Universal</CommonTags>
<CommonTags Condition="'$(PackageIdVariant)' == 'WinUI'">$(CommonTags);Uno</CommonTags>
<CommonTags>$(CommonTags);WinUI;Platform</CommonTags>
<!-- The Uno packages have no Windows assets, so they aren't tagged as Windows App SDK or UWP packages -->
<CommonTags Condition="'$(PackageIdVariant)' != 'Uno'">$(CommonTags);UWP;WindowsAppSDK;WASDK;WinAppSDK;Universal</CommonTags>
<CommonTags Condition="'$(PackageIdVariant)' == 'Uno'">$(CommonTags);Uno</CommonTags>
<PackageTags Condition="'$(PackageTags)' != ''">$(CommonTags);$(PackageTags)</PackageTags>
<PackageTags Condition="'$(PackageTags)' == ''">$(CommonTags)</PackageTags>
</PropertyGroup>
Expand Down
7 changes: 5 additions & 2 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ Check out our [Windows Community Toolkit Wiki](https://aka.ms/wct/wiki) page to

NuGet is a standard package manager for .NET applications which is built into Visual Studio. When you open solution in Visual Studio, choose the *Tools* menu > *NuGet Package Manager* > *Manage NuGet packages for solution…*

There are now two sets of packages for each component:
There are now three sets of packages for each component, one per UI framework:

- `CommunityToolkit.Uwp.*` for UWP + WinUI 2
- `CommunityToolkit.WinUI.*` for Windows App SDK + WinUI 3 or Uno.WinUI (Uno Platform apps should use these packages)
- `CommunityToolkit.WinUI.*` for Windows App SDK + WinUI 3
- `CommunityToolkit.Uno.*` for Uno Platform (Uno.WinUI) apps

A package only contains the assets of its own UI framework: Uno Platform apps must use the `CommunityToolkit.Uno.*` packages, which have no Windows assets (an app that targets both Uno and Windows must reference the `Uno` packages only for its Uno target frameworks and the `WinUI` packages for its Windows one). Components that only support UWP and Windows App SDK have no `Uno` package.


## 💠 Principles
Expand Down
4 changes: 3 additions & 1 deletion components/Animations/src/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ This package contains the following in the `CommunityToolkit.WinUI.Animations` n

If you're developing with _UWP/WinUI 2_ you should be using the `CommunityToolkit.Uwp.Animations` package.

If you're developing with _WindowsAppSDK/WinUI 3 or Uno.WinUI_ you should be using the `CommunityToolkit.WinUI.Animations` package.
If you're developing with _WindowsAppSDK/WinUI 3_ you should be using the `CommunityToolkit.WinUI.Animations` package.

If you're developing with _Uno Platform (Uno.WinUI)_ you should be using the `CommunityToolkit.Uno.Animations` package.

## Documentation

Expand Down
4 changes: 3 additions & 1 deletion components/Behaviors/src/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ This package contains the following in the `CommunityToolkit.WinUI.Behaviors` na

If you're developing with _UWP/WinUI 2_ you should be using the `CommunityToolkit.Uwp.Behaviors` package.

If you're developing with _WindowsAppSDK/WinUI 3 or Uno.WinUI_ you should be using the `CommunityToolkit.WinUI.Behaviors` package.
If you're developing with _WindowsAppSDK/WinUI 3_ you should be using the `CommunityToolkit.WinUI.Behaviors` package.

If you're developing with _Uno Platform (Uno.WinUI)_ you should be using the `CommunityToolkit.Uno.Behaviors` package.

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion components/CameraPreview/src/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This package contains the following controls in the `CommunityToolkit.WinUI.Cont

If you're developing with _UWP/WinUI 2_ you should be using the `CommunityToolkit.Uwp.Controls.CameraPreview` package.

If you're developing with _WindowsAppSDK/WinUI 3 or Uno.WinUI_ you should be using the `CommunityToolkit.WinUI.Controls.CameraPreview` package.
If you're developing with _WindowsAppSDK/WinUI 3_ you should be using the `CommunityToolkit.WinUI.Controls.CameraPreview` package.

## WinUI Resources (UWP)

Expand Down
4 changes: 3 additions & 1 deletion components/Collections/src/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ This package contains the following in the `CommunityToolkit.WinUI.Collections`

If you're developing with _UWP/WinUI 2_ you should be using the `CommunityToolkit.Uwp.Collections` package.

If you're developing with _WindowsAppSDK/WinUI 3 or Uno.WinUI_ you should be using the `CommunityToolkit.WinUI.Collections` package.
If you're developing with _WindowsAppSDK/WinUI 3_ you should be using the `CommunityToolkit.WinUI.Collections` package.

If you're developing with _Uno Platform (Uno.WinUI)_ you should be using the `CommunityToolkit.Uno.Collections` package.

## Documentation

Expand Down
Loading
Loading