Skip to content

MultiBuildDotNet automates the build process for multiple Visual Studio C# solutions. It supports configuration via JSON files, allowing for dependency management and and custom build commands. It can also detect changes between commits and dynamically adjust the build.

License

Notifications You must be signed in to change notification settings

EntityProcess/MultiBuildDotNet

Repository files navigation

MultiBuildDotNet

MultiBuildDotNet is a .NET console app designed to sequentially build multiple .NET solutions based on a configuration file. The app allows users to specify custom commands (e.g., dotnet build) to run for each solution and substitutes the solution paths dynamically. It also reads a master build order config file to ensure that solutions are built in the correct order.

Features

  • Build multiple .NET solutions in a specified order.
  • Supports customizable build commands using placeholders for solution paths.
  • Reads a master build order file to ensure the correct order of solutions.
  • Compare the latest commits in the current branch and another branch (e.g., master) to find solutions that need rebuilding.

Installation

  1. Clone the repository:

    git clone https://github.com/EntityProcess/MultiBuildDotNet.git
    cd MultiBuildDotNet
  2. Build the console app:

    dotnet publish -c Release

Usage

  1. Create a config.json file in the project directory. This file will contain the list of solution file paths and the command template you want to run.

    Example config.json:

    {
      "CommandTemplate": "dotnet build \"{solution}\"",
      "WorkingDirectory": "C:/path/to/your/repo",
      "Solutions": [
        "C:/Projects/Solution1.sln",
        "C:/Projects/Solution2.sln"
      ]
    }
    • Replace "dotnet build {solution}" with the desired command.
    • Use {solution} as the placeholder for each solution's path, which will be replaced by the entries in the Solutions array.
    • Paths containing backslashes (\) in Solutions will be converted to forward slashes (/).
  2. Optionally, create a masterBuildOrder.json file in the project directory. This file contains the solutions in the order they should be built:

    Example masterBuildOrder.json:

    {
      "Solutions": [
        "C:/Projects/Solution1.sln",
        "C:/Projects/Solution2.sln"
      ]
    }

    If masterBuildOrder.json exists, the app will reorder the solutions from config.json based on the master build order specified in masterBuildOrder.json. Solutions in config.json that are not found in the master build order will be appended in their original order.

  3. Run the app:

    MultiBuildDotNet.exe

    The app will execute the command for each solution sequentially. If a command fails, the process will stop, and the name of the failed solution will be displayed.

  4. You can specify two Git commits to find solutions that contain changes between those commits. The app will use the changed solutions between the specified commits, but any solutions in config.json that do not appear in the list of changed solutions will also be included in the build process.

    Example usage with commit hashes:

    MultiBuildDotNet.exe <commit1> <commit2>

    Example:

    MultiBuildDotNet.exe abc123 def456

    If no commit arguments are provided, the app will use the existing solutions from config.json.

  5. You can compare the latest commit in the current branch with the latest commit in another branch (e.g., master). The app will rebuild solutions that have changes between these commits.

    Example usage with branch comparison:

    MultiBuildDotNet.exe -b master

Example Output

Running command: dotnet build C:/Projects/Solution1.sln
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET
...

Running command: dotnet build C:/Projects/Solution2.sln
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET
...
Build failed for solution: C:/Projects/Solution2.sln

Configuration File

  • config.json: Contains the command template, working directory, and list of solution paths.
  • masterBuildOrder.json: Contains the solutions in the order they should be built.

Example config.json:

{
  "CommandTemplate": "dotnet build {solution}",
  "WorkingDirectory": "C:/path/to/your/repo",
  "Solutions": [
    "C:/Projects/Solution1.sln",
    "C:/Projects/Solution2.sln"
  ]
}

Requirements

  • .NET SDK (8.0 or later)

Example masterBuildOrder.json:

{
  "Solutions": [
    "C:/Projects/Solution2.sln",
    "C:/Projects/Solution1.sln"
  ]
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributions

Contributions are welcome! Feel free to open issues or submit pull requests for improvements and bug fixes.

About

MultiBuildDotNet automates the build process for multiple Visual Studio C# solutions. It supports configuration via JSON files, allowing for dependency management and and custom build commands. It can also detect changes between commits and dynamically adjust the build.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages