Skip to main content

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

ParameterDescription
Step NameOptional step name. Defaults to the runner name if not specified.
Working DirectoryDirectory where the build runs.
SolutionPath to the solution file to build.
ConfigurationBuild configuration (e.g., Debug or Release).
ParametersAdditional 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.