Based on the Saury.Revit.Template dotnet template, create a fully configured Revit 2026 add-in project (MVVM + DI architecture) through an interactive process.
Workflow
Execute the following steps in order, and proceed to the next step only after each step is completed.
Step 1: Interactively confirm the project configuration
Before executing any command, you must confirm the following information with the user:
Required:
- Project name — must be a valid C# namespace name (e.g.,
Acme.WallTools、JD.RevitHelper), defaultRevitDemoorRevitTest. This name will be used for the solution, project folder, namespace, assembly, addin file, and Ribbon tab. - Project creation directory — defaults to the current working directory.
Optional (has default values, only needs confirmation):
3. Revit version — default 2026, specified via the --RevitVersion parameter.
After the user confirms, summarize the configuration and have the user give final confirmation before executing.
Step 2: Check and install the .NET environment
Detection process (execute in order):
- Detect whether the dotnet CLI exists:
where dotnet
- If the command exists, detect the SDK version:
dotnet --list-sdks
Check whether the output contains 8.0 or a higher SDK version.
- Determine the result:
- dotnet CLI exists and SDK 8.0+ is installed → skip, proceed to the next step
- dotnet CLI exists but no SDK or insufficient version → need to install the SDK
- dotnet CLI does not exist → need a full installation
Installation methods (try in order of priority):
winget install Microsoft.DotNet.SDK.8
- After installation is complete, re-verify:
where dotnet && dotnet --list-sdks - If
wingetis unavailable, use the official script to install instead:
Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1
./dotnet-install.ps1 -Channel 8.0
- If all the above methods fail, tell the user to manually download .NET 8.0 SDK
Step 3: Install the template
# 检查是否已安装
dotnet new list saury-revit
- If already installed → skip, inform the user that it is currently installed
- If not installed → perform the installation:
dotnet new install Saury.Revit.Template
- If an update is needed →
dotnet new install Saury.Revit.Template --force
Step 4: Create the project
dotnet new saury-revit -n <项目名称> -o <输出目录>
| Parameter | Description | Example |
|---|---|---|
-n |
Project name (replaces all Saury.Revit.Template) |
Acme.WallTools |
-o |
Output directory | ./Acme.WallTools |
--RevitVersion |
Revit version (default 2026) | 2026 |
The template automatically completes:
- Global replacement of
Saury.Revit.Template→ user project name - Automatically generate a unique GUID to replace
ADDIN-GUID-PLACEHOLDER - Exclude
.template.config/、bin/、obj/、.vs/、Logs/、*.user
Step 5: Verify the project structure
After creation, list the directory to confirm the structure is complete:
<项目名称>/
├── <项目名称>.slnx
└── <项目名称>/
├── Commands/AboutCommand.cs
├── Extensions/DataContextExtension.cs
├── Models/AboutInfo.cs
├── ViewModels/AboutViewModel.cs
├── Views/AboutView.xaml(.cs)
├── Resources/Icons/about.png
├── Resources/Styles/ButtonStyles.xaml
├── Services/Interfaces/
├── Application.cs
├── Host.cs
├── appsettings.json
├── <项目名称>.addin
└── <项目名称>.csproj
Step 6: Build verification
cd <输出目录>
dotnet restore
dotnet build --configuration Debug_R26
Key: This project uses Debug_R26 / Release_R26,Do notuse the standard Debug / Release, otherwise the build will fail.
After a successful build, the compiled output is automatically copied to C:\ProgramData\Autodesk\Revit\Addins\2026\。
Step 7: Tell the user how to use it
After a successful build, show the user the following usage instructions:
Debug launch configuration
- Modify the Revit path — Open
<项目名称>.csproj, find theStartProgramproperty, and confirm that the path points to the local Revit installation location:
<StartProgram>C:\Program Files\Autodesk\Revit 2026\Revit.exe</StartProgram>
If Revit is installed in a non-default path, it must be changed to the actual path.
- Open with Visual Studio or Rider
<项目名称>.slnx - Select the build configuration
Debug_R26(toolbar dropdown,do not selectDebug) - Click Start/F5 — automatically compile → copy the output to the Addins directory → start Revit → attach the debugger
- After Revit starts — find the plugin button in the Ribbon tab and click it to trigger breakpoint debugging
Subsequent customization
- Vendor information(
<项目名称>.addin)— VendorId、VendorDescription、VendorEmail - About page information(
Models/AboutInfo.cs)— GiteeUrl、Description - Add new features — see architecture.md
Add new features
When the user requests adding a new feature to an already created project, read references/architecture.md to get the complete code templates and rule constraints, and strictly follow the A→F six-step process:
- Model →
Models/directory - ViewModel →
ViewModels/directory (partial class, inheritObservableObject) - View →
Views/directory (constructor injects ViewModel) - Command →
Commands/directory ([Transaction(TransactionMode.Manual)]) - DI registration →
Host.cs(AddTransient) - Ribbon button →
Application.cstheCreateRibbonmethod
Prohibitions
- Do not use the
Debug/Releaseconfiguration; only useDebug_R26/Release_R26 - Do not manually
newView or ViewModel; it must be obtained throughHost.GetService<T>()Get - Do not write business logic in the View code-behind
- Do not directly call
MessageBoxin the ViewModel or operate onWindow - Do not hard-code configuration values; use
appsettings.json+IOptions<T> - Unless the user explicitly requests it, do not delete the example About feature