Skip to content

[Bug] GitVersion.MsBuild fails to create named mutex in Linux builds with concurrent projects #5367

Closed as not planned

Description

@dorssel

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

GitVersion package

GitVersion.MsBuild

GitVersion version

6.8.2

Operating system

Linux

What are you seeing?

Linux runners on GitHub have switched to a more hardened sandbox. They now reject the creation of the GitVersion mutex, see

using var mutex = new Mutex(true, $@"Global\gitversion{mutexName}", out var acquired);

The error produced is:

The system cannot open the device or file specified. : 'Global\gitversionhomerunnerworkdotnet-debouncedotnet-debounce.git'

The reason is that the Linux sandbox rejects the \ in the path. I understand that the Global\ prefix is for Windows. Maybe the name should be OS-dependent, so Linux is not confronted with backslashes.

EDIT: see analysis from @arturcic below, which is correct

What is expected?

GitVersion works on GitHub Linux runners.

Steps to Reproduce

Create a .NET solution with two (or more) projects using GitVersion.MsBuild that can build concurrently and use a GitHub Linux runner.

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

The system cannot open the device or file specified. : 'Global\gitversionhomerunnerworkdotnet-debouncedotnet-debounce.git'
/home/runner/work/dotnet-debounce/dotnet-debounce/.nuget/packages/gitversion.msbuild/6.8.2/tools/GitVersion.MsBuild.targets(32,9): error MSB3073: The command "dotnet --roll-forward Major "/home/runner/work/dotnet-debounce/dotnet-debounce/.nuget/packages/gitversion.msbuild/6.8.2/tools/net8.0/gitversion.dll" "/home/runner/work/dotnet-debounce/dotnet-debounce/Debounce"  -output file -outputfile "obj/gitversion.json" -allowshallow" exited with code 1. [/home/runner/work/dotnet-debounce/dotnet-debounce/Debounce/Debounce.csproj::TargetFramework=netstandard2.0]

Activity

  1. changed the title [-][ISSUE]: Mutex name (containing 'Global\') fails on GitHub CodeQL Linux runners[/-] [+][ISSUE]: Mutex name (containing 'Global\') fails on GitHub Linux runners[/+] on Oct 15, 2026
  2. added this to the 7.0.x milestone on Oct 15, 2026
  3. changed the title [-][ISSUE]: Mutex name (containing 'Global\') fails on GitHub Linux runners[/-] [+][Bug] GitVersion.MsBuild fails to create named mutex in Linux CodeQL builds[/+] on Oct 15, 2026
  4. arturcic commented on Oct 15, 2026

    @arturcic
    Member

    Thanks for reporting this. Codex here, responding on behalf of @arturcic.

    This appears related to the .NET Unix named-mutex storage change, introduced in .NET 8.0.32 and 10.0.13. Named mutexes now default to user scope and require accessible user-owned storage. On Linux, XDG_RUNTIME_DIR can provide that storage.

    We reproduced the same exception using the published GitVersion.MsBuild 6.8.2 executable, without changing its binaries:

    Runtime Read-only home directory With private XDG_RUNTIME_DIR
    8.0.31 / 10.0.12 Works Works
    8.0.32 / 10.0.13 Fails with the mutex exception Works

    We tested these comparisons on Linux ARM64 and additionally verified the .NET 8 comparison on AMD64. Removing the Global\ prefix did not resolve the failure, so the backslash does not appear to be the cause.

    We have not captured the exact storage conditions inside your failing CodeQL job, but the runtime change provides a reproducible explanation.

    Could you try adding this step before dotnet restore and dotnet build in the Linux job?

    - name: Prepare private runtime directory
      if: runner.os == 'Linux'
      shell: bash
      run: |
        gitversion_runtime_dir="$(mktemp -d "${RUNNER_TEMP}/gitversion-runtime.XXXXXX")"
        printf 'XDG_RUNTIME_DIR=%s\n' "$gitversion_runtime_dir" >> "$GITHUB_ENV"

    mktemp -d creates a private directory owned by the runner user. Provision it once per job so subsequent steps and concurrent GitVersion processes inherit the same directory. We verified that using separate directories per invocation breaks mutex coordination.

    Please let us know whether this allows your Linux CodeQL build to complete.

  5. changed the title [-][Bug] GitVersion.MsBuild fails to create named mutex in Linux CodeQL builds[/-] [+][Bug] GitVersion.MsBuild fails to create named mutex in Linux builds with concurrent projects[/+] on Oct 15, 2026
  6. dorssel commented on Oct 15, 2026

    @dorssel
    Author

    Yes, you are right! My original analysis was incorrect.

    It is a concurrency problem when multiple projects using GitVersion.MsBuild can build concurrently as the first projects to build. The two GitVersion jobs clash. In my case it was actually a single project that builds concurrently for both net8.0 and netstandard2.0 targets (using the .NET 10.0.402 compiler).

    It also happens on normal builds, not related to just CodeQL. It is indeed the update to .NET SDK 10.0.402.

    Workaround fixes it!

  7. dorssel commented on Oct 15, 2026

    @dorssel
    Author

    Oops ... cheered too soon. The same workaround does not work for normal builds. See https://github.com/dorssel/dotnet-debounce/actions/runs/38825430102/job/116731673347?pr=462

    I applied the same for both workflows: dorssel/dotnet-debounce@c724269

    codeql.yml works now, dotnet.yml still does not

  8. modified the milestones: 7.0.x, 7.x on Oct 16, 2026
  9. arturcic commented on Oct 16, 2026

    @arturcic
    Member

    Thanks for the additional details. Codex here, responding on behalf of @arturcic.

    Could you try a serial GitVersion warm-up after restore and before the parallel build, keeping your existing private XDG_RUNTIME_DIR setup?

    - name: Warm up GitVersion serially
      if: runner.os == 'Linux'
      shell: bash
      run: |
        dotnet msbuild Debounce/Debounce.csproj \
          -target:GetVersion \
          -property:TargetFramework=net8.0 \
          -property:Configuration=Release \
          -maxcpucount:1 -nodeReuse:false \
          -p:ContinuousIntegrationBuild=true

    Warm-up and all subsequent GitVersion processes must run as the same user with the same XDG_RUNTIME_DIR. Keep the directory intact between steps; the normal build can remain parallel.

    We tested your failing revision, c724269df2f411d11e0218f8c680bb9b8ff7ff5e, with SDK 10.0.402, GitVersion.MsBuild 6.8.2, and both netstandard2.0 and net8.0 targets:

    • All 15 warmed multi-target builds passed, covering GitVersion running on .NET 10.0.13 and 8.0.32.
    • The full solution build passed with zero warnings or errors.
    • Mutual exclusion remained effective: both actual GitVersion invocations blocked behind a held repository mutex and completed after release. An additional 80 competing helper processes showed no overlapping critical sections.

    There are two important limitations: all 15 controls without explicit warm-up also passed, and our Linux AMD64 containers ran under emulation on an ARM64 host. These results establish that the workaround preserves coordination in our tests, but do not prove it fixes your failure.

    Could you try this on the failing GitHub Actions job and share the resulting run, including the logs if it still fails?

  10. dorssel commented on Oct 16, 2026

    @dorssel
    Author

    Yes, that works. Forcing a single GitVersion instance to calculate the version, and then letting everything build (concurrently) is working again.

  11. dorssel commented on Oct 16, 2026

    @dorssel
    Author

    Minimized the changes to make it work. It is just the concurrency that needs to be avoided (the mutex problem).

          - name: Warm up GitVersion serially
            # Workaround for https://github.com/GitTools/GitVersion/issues/5367
            run: |
              dotnet msbuild Debounce/Debounce.csproj \
                -target:GetVersion \
                -property:TargetFramework=net8.0 \
                -property:Configuration=Release
    
  12. arturcic commented on Oct 17, 2026

    @arturcic
    Member

    Thanks for confirming that the minimal serial warm-up works, and for narrowing it down. Codex here, responding on behalf of @arturcic.

    Investigating and validating the underlying concurrency fix will take more time. Since the workaround unblocks your builds while keeping the remaining build parallel, we’re closing this issue for now.

    Thanks again for the clear reproducer and for testing the workaround with us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions