MSBuild Project Files
Overview
The Krypton Toolkit build system uses MSBuild project files (.proj) to orchestrate multi-project builds, NuGet package creation, and distribution archive generation. Project files are located under Scripts/Build/, Scripts/VS2022/, and Scripts/Current/; GitHub Actions use Scripts/Build/.
Project File Structure
All .proj files follow a similar structure:
- Import global properties
- Define configuration-specific properties
- Define targets for Clean, Restore, Build
- Define targets for package creation
- Define targets for archive creation
Core Project Files
build.proj - Stable/Release Builds
Purpose: Builds stable production releases
Key Properties:
<Configuration>Release</Configuration>
<ReleaseBuildPath>..\Bin\Release\Zips</ReleaseBuildPath>
<ReleaseZipName>Krypton-Release</ReleaseZipName>
Available Targets:
Clean
Cleans all Krypton component projects for the Release configuration.
msbuild build.proj /t:Clean
Restore
Restores NuGet packages for all Krypton components.
msbuild build.proj /t:Restore
Build (Default)
Builds all Krypton components. Depends on Restore.
msbuild build.proj /t:Build
CleanPackages
Deletes existing NuGet packages from Bin/Packages/Release/.
msbuild build.proj /t:CleanPackages
PackLite
Creates NuGet packages for "lite" target frameworks (net48, net481, net8.0+).
- Cleans projects and NuGet assets
- Restores with
TFMs=lite - Packs with
TFMs=lite
msbuild build.proj /t:PackLite
PackAll
Creates NuGet packages for all target frameworks (net472-net10.0-windows).
- Cleans projects and NuGet assets
- Restores with
TFMs=all - Packs with
TFMs=all
msbuild build.proj /t:PackAll
Pack
Master packaging target. Depends on CleanPackages, PackLite, and PackAll. Generates both Lite and full packages.
msbuild build.proj /t:Pack
Push
Publishes NuGet packages to NuGet.org using nuget.exe.
msbuild build.proj /t:Push
Note: Requires NUGET_API_KEY environment variable or configured API key.
CreateReleaseZip
Creates ZIP archive of Release binaries.
- Uses 7-Zip if available
- Falls back to PowerShell
Compress-Archive - Output:
Bin/Release/Zips/Krypton-Release_<yyyyMMdd>.zip
msbuild build.proj /t:CreateReleaseZip
CreateReleaseTar
Creates TAR.GZ archive of Release binaries.
- Tries 7-Zip (recommended)
- Falls back to Windows 10/11 tar command
- Falls back to Git Bash tar
- Output:
Bin/Release/Zips/Krypton-Release_<yyyyMMdd>.tar.gz
msbuild build.proj /t:CreateReleaseTar
CreateAllReleaseArchives
Creates both ZIP and TAR.GZ archives.
msbuild build.proj /t:CreateAllReleaseArchives
canary.proj - Beta Pre-Release Builds
Purpose: Builds beta pre-release packages for early adopters
Key Properties:
<Configuration>Canary</Configuration>
<CanaryBuildPath>..\Bin\Canary\Zips</CanaryBuildPath>
<CanaryZipName>Krypton-Canary</CanaryZipName>
Available Targets:
Clean- Clean Canary configurationRestore- Restore packagesBuild- Build Canary configurationCleanPackages- Delete packages fromBin/Packages/Canary/PackAll- Create Canary packages (all TFMs, no Lite variant)Pack- Master packaging target (CleanPackages + PackAll)Push- Publish Canary packagesCreateCanaryZip- Create Canary ZIP archiveCreateCanaryTar- Create Canary TAR.GZ archiveCreateAllCanaryArchives- Create both archives
Key Differences from Stable:
- No
PackLitetarget (Canary always packs all TFMs) - Packages get
-betasuffix in NuGet - Outputs to
Bin/Canary/andBin/Packages/Canary/
nightly.proj - Alpha Nightly Builds
Purpose: Builds bleeding-edge alpha releases for developers and testers
Key Properties:
<Configuration>Nightly</Configuration>
<NightlyBuildPath>..\Bin\Nightly\Zips</NightlyBuildPath>
<NightlyZipName>Krypton-Nightly</NightlyZipName>
Available Targets:
Clean- Clean Nightly configurationRestore- Restore packagesBuild- Build Nightly configurationRebuild- Clean + BuildCleanPackages- Delete packages fromBin/Packages/Nightly/PackAll- Create Nightly packages (all TFMs)Pack- Master packaging targetPush- Publish Nightly packagesCreateNightlyZip- Create Nightly ZIP archiveCreateNightlyTar- Create Nightly TAR.GZ archiveCreateAllArchives- Create both archives
Key Differences:
- Includes
Rebuildtarget - Packages get
-alphasuffix in NuGet - Outputs to
Bin/Nightly/andBin/Packages/Nightly/
debug.proj - Debug Builds
Purpose: Local development debug builds
Key Properties:
<Configuration>Debug</Configuration>
Available Targets:
Clean- Clean Debug configurationRestore- Restore packagesBuild- Build Debug configuration
Key Differences:
- No packaging or archive targets
- Simplified for local development
installer.proj - Installer Builds
Purpose: Builds packages for demo installers
Key Properties:
<Configuration>Installer</Configuration>
Available Targets:
Clean- Clean Installer configurationRestore- Restore packagesBuild- Build Installer configurationCleanPackages- Delete packages fromBin/Packages/Installer/PackAll- Create Installer packagesPack- Master packaging targetPush- Publish Installer packagesCreateNightlyZip- Create Installer ZIP (reuses Nightly zip logic)
Special Notes:
- WiX installers require build numbers ≤ 256
- Version uses month number for Build component
Project File Patterns
Project Selection Pattern
All .proj files use this pattern to select Krypton projects:
<ItemGroup>
<Projects Include="..\Source\Krypton Components\Krypton.*\*.csproj" />
</ItemGroup>
This selects:
Krypton.Toolkit\Krypton.Toolkit 2022.csprojKrypton.Ribbon\Krypton.Ribbon 2022.csprojKrypton.Navigator\Krypton.Navigator 2022.csprojKrypton.Workspace\Krypton.Workspace 2022.csprojKrypton.Docking\Krypton.Docking 2022.csproj
NuGet Asset Cleanup Pattern
Before packing, intermediate NuGet files are deleted:
<ItemGroup>
<NugetAssets Include="..\Source\Krypton Components\Krypton.*\obj\*.json" />
<NugetAssets Include="..\Source\Krypton Components\Krypton.*\obj\*.cache" />
<NugetAssets Include="..\Source\Krypton Components\Krypton.*\obj\*.g.targets" />
<NugetAssets Include="..\Source\Krypton Components\Krypton.*\obj\*.g.props" />
</ItemGroup>
<Delete Files="@(NugetAssets)" />
This ensures clean package generation.
MSBuild Invocation Pattern
Projects are built with configuration and TFM control:
<MSBuild Projects="@(Projects)"
Properties="Configuration=$(Configuration);TFMs=all"
Targets="Build" />
Key properties passed:
Configuration- Debug, Release, Canary, Nightly, InstallerTFMs-lite,all, or empty
Archive Generation
ZIP Archives
Uses multiple fallback methods:
- 7-Zip (preferred): Fast, best compression
- PowerShell Compress-Archive: Built-in Windows
Example:
<!-- 7-Zip method -->
<Exec Command="7z.exe a -tzip "$(ReleaseBuildPath)\$(ReleaseZipName)_$(StringDate).zip" "..\Bin\Release\*" -x!*.json -x!*.pdb"
Condition="Exists('C:\Program Files\7-Zip\7z.exe')" />
<!-- PowerShell fallback -->
<Exec Command="powershell.exe -Command "Get-ChildItem '..\Bin\Release\*' -Recurse | Where-Object {$_.Extension -notin '.json','.pdb'} | Compress-Archive -DestinationPath '$(ReleaseBuildPath)\$(ReleaseZipName)_$(StringDate).zip' -Force""
Condition="!Exists('C:\Program Files\7-Zip\7z.exe')" />
TAR.GZ Archives
Uses multiple fallback methods:
- 7-Zip: Creates tar then compresses to tar.gz
- Windows tar: Native tar in Windows 10/11
- Git Bash tar: Uses Git's bundled tar
Custom Target Execution
Execute Specific Target
msbuild build.proj /t:TargetName
Execute Multiple Targets
msbuild build.proj /t:Clean;Build
Override Configuration
msbuild build.proj /t:Build /p:Configuration=Debug
Override TFMs
msbuild build.proj /t:Build /p:TFMs=lite
Verbose Output
msbuild build.proj /t:Build /v:detailed
Save to Log File
msbuild build.proj /t:Build /fl /flp:logfile=build.log
Binary Log
msbuild build.proj /t:Build /bl:build.binlog
Best Practices
1. Clean Before Major Builds
msbuild build.proj /t:Clean;Build
2. Use Rebuild for Complete Rebuild
msbuild nightly.proj /t:Rebuild
3. Test Packaging Locally Before Push
msbuild build.proj /t:Pack
# Verify packages in Bin/Packages/Release/
msbuild build.proj /t:Push
4. Use Binary Logs for Troubleshooting
msbuild build.proj /t:Build /bl:build.binlog
# View with MSBuild Structured Log Viewer
5. Parallel Builds
MSBuild automatically parallelizes project builds. For explicit control:
msbuild build.proj /t:Build /m:4
Related Documentation
- Build Scripts - Command-line build scripts
- Directory.Build Configuration - Property inheritance
- NuGet Packaging - Package configuration
- Version Management - Versioning details