This guide is based on my experience installing and running the dotnet scaffold repository locally.
Clone the repository from GitHub:
https://github.com/dotnet/Scaffolding
I recommend cloning it under your user profile directory.
-
Navigate to the cloned
Scaffoldingdirectory. Edit as needed. -
Install dev package
from cmd: run
scripts\install-scaffold.cmdOR from powershell run:scripts\install-scaffold.shThese scripts will install the Nuget Packages associated with your local changes on your machine.
-
Test changes
From a cmd (or powershell), test your changes locally. Run
dotnet scaffoldor the command you are trying to test. For debugging testing, attach the debugger as outlined below and repeat these steps.
-
Open the
all.slnsolution in a separate instance of Visual Studio. -
Set any breakpoints you want to hit.
-
Before running the install script, add the following line near the top of the project you want to debug (e.g.,
dotnet-scaffold-aspnet, etc.):System.Diagnostics.Debugger.Launch();
This will automatically launch a debugger. Otherwise, you’ll need to attach one manually.
-
In a terminal, navigate to a project that is ready for scaffolding (a relatively blank project with a basic model class).
-
Run
dotnet scaffoldfrom there.
- A preview version of the .NET SDK:
- It should closely match the version specified in the
global.jsonat the root of the scaffolding repo. - Reference: https://github.com/dotnet/sdk/blob/main/documentation/package-table.md
- It should closely match the version specified in the
- C# Dev Kit (if using Visual Studio Code)
.configfolders in the root of either the scaffolding project or the project you're scaffolding.- Missing or overlapping SDK versions:
- I encountered issues with two .NET 10.0 preview versions and had to delete the newer one.
-
generate a personal access token (PAT). a. go to Azure DevOps b. click the User settings next to your picture in the top right c. click on Personal Access Token toward the bottom of the menu d. click "+ New Token" and copy it. You will need this token to run the following scripts
-
Log in to az CLI with your Microsoft account with
az login -
set your PAT environment variable with running
$env:PAT = [your PAT] -
run
scripts\download-artifacts.ps1optionally, specify the branch for example:powershell.exe -File c:\Scaffolding\scripts\download-artifacts.ps1 -Branch release/10.0, branch defaults to main -
Ensure that the correct versions are installed. The installed packages should be Microsoft.dotnet-msidenity, dotnet-aspnet-codegenerator, and Microsoft.dotnet-scaffold.