Generate complete AvaloniaUI projects with professional structure and best practices.
Overview
The ProjectGeneratorTool creates production-ready AvaloniaUI projects with various templates and configurations. It supports MVVM architecture, cross-platform development, and includes all necessary project files.
Features
Multiple Templates: MVVM, Basic, Cross-platform
Platform Support: Desktop, Mobile, Universal
Best Practices: Industry-standard project structure
Performance Optimized: Async file generation
Validation: Comprehensive input checking
Usage
Basic Project Creation
1
"Create a new AvaloniaUI project called MyApp"
This creates a basic project with:
Standard project structure
Modern .NET 9.0 targeting
Essential AvaloniaUI packages
Basic window and app setup
MVVM Project
1
"Create an MVVM AvaloniaUI project called MyMvvmApp"
Generates:
ViewModels with ReactiveUI
Proper MVVM structure
Data binding examples
Command patterns
Cross-Platform Project
1
"Create a cross-platform AvaloniaUI project called MyCrossPlatformApp for desktop and mobile"
Creates:
Shared UI components
Platform-specific projects
Conditional compilation
Mobile optimizations
Parameters
Required
projectName: Name of the project (validates against naming conventions)
Optional
template: Project template type
"mvvm" (default) - Full MVVM with ReactiveUI
"basic" - Simple application structure
"crossplatform" - Multi-platform setup
platforms: Target platforms
"desktop" (default) - Windows, macOS, Linux
"mobile" - Android, iOS
"all" - Desktop and mobile
outputDirectory: Where to create the project (defaults to current directory)
<Windowxmlns="https://github.com/avaloniaui"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:vm="using:MyApp.ViewModels"x:Class="MyApp.MainWindow"x:DataType="vm:MainWindowViewModel"Title="MyApp"Width="800"Height="600"><Design.DataContext><vm:MainWindowViewModel/></Design.DataContext><StackPanelMargin="20"Spacing="10"><TextBlockText="Welcome to AvaloniaUI!"FontSize="24"FontWeight="Bold"/><TextBlockText="{Binding Greeting}"FontSize="16"/><StackPanelOrientation="Horizontal"Spacing="10"><TextBoxText="{Binding Name}"Watermark="Enter your name"Width="200"/><ButtonCommand="{Binding GreetCommand}"Content="Greet"/></StackPanel><TextBlockText="{Binding GreetingMessage}"FontWeight="Bold"Foreground="Blue"/></StackPanel></Window>
usingSystem.Reactive;usingReactiveUI;namespaceMyApp.ViewModels;publicclassMainWindowViewModel:ViewModelBase{privatestring_name=string.Empty;privatestring_greetingMessage=string.Empty;publicstringGreeting=>"Welcome to Avalonia!";publicstringName{get=>_name;set=>this.RaiseAndSetIfChanged(ref_name,value);}publicstringGreetingMessage{get=>_greetingMessage;set=>this.RaiseAndSetIfChanged(ref_greetingMessage,value);}publicReactiveCommand<Unit,Unit>GreetCommand{get;}publicMainWindowViewModel(){GreetCommand=ReactiveCommand.Create(ExecuteGreet);}privatevoidExecuteGreet(){GreetingMessage=string.IsNullOrWhiteSpace(Name)?"Please enter your name!":$"Hello, {Name}! Welcome to AvaloniaUI!";}}
Building and Running
After project generation:
1
2
cd MyApp
dotnet run
For cross-platform projects:
1
2
3
4
5
# Run desktop version
dotnet run --project MyApp.Desktop.csproj
# Build for mobile (requires additional setup)
dotnet build MyApp.Mobile.csproj
Validation
The tool validates:
Project names - Valid C# identifiers, no reserved words