MSBuild Runner
The MSBuild Runner compiles and builds .NET projects and Visual Studio solution files using Microsoft’s MSBuild engine. It provides fine-grained control over build configurations, supports custom parameters, and integrates seamlessly with the BuildNinja environment for automated .NET builds.
When to Use
Use the MSBuild Runner when you need to:
- Build .NET Framework, .NET Core, or Visual Studio projects.
- Compile large or enterprise-level applications.
- Manage solution-level builds with multiple configurations.
- Leverage MSBuild features such as custom targets, properties, and parameters.
Parameters
| Parameter | Description |
|---|---|
| Step Name | Optional step name. Defaults to the runner name if not specified. |
| Working Directory | Directory where the build runs. |
| Solution | Path to the solution file to build. |
| Configuration | Build configuration (e.g., Debug or Release). |
| Parameters | Additional parameters to pass to MSBuild. |
Typical Use Cases
Common scenarios for using the MSBuild Runner include:
- Building web APIs, desktop applications, and background services.
- Running CI builds for .NET repositories.
- Producing deployable binaries and packaged artifacts.
- Automating solution-level builds with multiple projects and configurations.
Example
This example demonstrates how to build a Visual Studio solution using the MSBuild Runner.
Scenario
Build a solution in Release mode.
Configuration settings:
- Step Name: Build Solution
- Working Directory:
C:\Projects\MyApp - Solution:
MyApp.sln - Configuration:
Release - Parameters:
/m /p:Platform=x64
Limitations
- Requires MSBuild to be installed on the agent machine.
- Primarily Windows-centric; limited support for cross-platform builds.
- Large solutions may increase build time.
- Offers less flexibility than raw scripting for complex or dynamic scenarios.
Best Practices
- Keep solution and project files clean and well-structured.
- Use consistent build configurations across environments.
- Cache dependencies where possible to reduce build time.
- Monitor build performance to identify bottlenecks or optimizations.