Skip to content

Getting started

Michael Hawker MSFT (XAML Llama) edited this page Sep 25, 2023 · 2 revisions

To get started with the Windows Community Toolkit, you can follow these steps:


Cloning the repository

git clone --recurse-submodules https://github.com/CommunityToolkit/Windows.git

The folder will contain a tooling and components folder. The latter contains all the individual Toolkit components.


Editing a component

In an existing component folder, you can run OpenSolution.bat to generate the .sln:

cd *path of your component*

.\OpenSolution.bat

The .sln` will open automatically, and contains the source project (component code), samples project (samples and documentation) and tests project (for all tests). image
You can test your component code by adding it to a sample, and use the different startup projects to test it on UWP, WinAppSDK or Uno.


Running the sample app

Run the following script to navigate to the cloned folder, install SlnGen and run GenerateAllSolutions.bat.

cd *path of your Toolkit folder*

dotnet tool restore

.\GenerateAllSolution.bat

This will generate and open the CommunityToolkit.AllComponents.sln. In Visual Studio, select the preferred startup project (Uwp (WinUI2), WinAppSDK (WinUI3) or Wasm (Uno).
image


Creating a new component

To create a new component run the following script:

cd *path of your Toolkit folder*

dotnet new --install .\tooling\ProjectTemplate\

cd components

dotnet new ctk-component -n MyExperimentNameHere

This will generate a new component folder that contains src, samples and tests folders.


FAQ

Errors that might come up when running the .bat files:

Error: Cannot be loaded because running scripts is disabled on this system

Make sure you set the execution policy. (More info: https://lazyadmin.nl/powershell/running-scripts-is-disabled-on-this-system/)

Error: Could not find a Visual Studio installation. Please run from a command window that has MSBuild.exe on the PATH or specify the full path to devenv.exe via the -vs command-line argument

Use Developer Command Prompt for VS2022, or add msbuild.exe to your PATH variables to use it in e.g. PowerShell. (More info: https://stackoverflow.com/a/12608705)

About Windows Community Toolkit

Usage

Contribution

Development/Testing

Project Structure

Clone this wiki locally