Skip to content

[Bug]: CS1705 with TUnit.Mocks.Http/Logger referencing a higher TUnit.Mocks version #5622

Description

@Zodt

Description

When building a test project that references TUnit.Mocks.Http, compilation fails with:

CSC: Error CS1705: Assembly "TUnit.Mocks.Http, Version=1.36.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c" uses "TUnit.Mocks, Version=1.36.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c" which has a higher version than referenced assembly "TUnit.Mocks" with identity "TUnit.Mocks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c".

Similarly with TUnit.Mocks.Logging:

CSC: Error CS1705: Assembly "TUnit.Mocks.Logging, Version=1.36.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c" uses "TUnit.Mocks, Version=1.36.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c" which has a higher version than referenced assembly "TUnit.Mocks" with identity "TUnit.Mocks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c".

Expected Behavior

The project should compile successfully when TUnit.Mocks.Http is referenced together with the rest of the TUnit packages.

Actual Behavior

Compilation fails with CS1705, indicating that TUnit.Mocks.Http depends on a newer TUnit.Mocks assembly version than the one resolved by the consuming project.

Steps to Reproduce

  1. Create or open a test project targeting modern .NET.
  2. Reference the following packages:
    • TUnit
    • TUnit.AspNetCore
    • TUnit.Mocks.Http
    • TUnit.Mocks.Logging
    • TUnit.Mocks.Assertions
  3. Build the project.
  4. The build fails with CS1705.

TUnit Version

1.36.0

.NET Version

net8.0 / net9.0 / net10.0

Operating System

Windows

IDE / Test Runner

dotnet CLI (dotnet test / dotnet run)

Error Output / Stack Trace

CSC: Error CS1705: Assembly "TUnit.Mocks.Http, Version=1.36.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c" uses "TUnit.Mocks, Version=1.36.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c" which has a higher version than referenced assembly "TUnit.Mocks" with identity "TUnit.Mocks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c".

CSC: Error CS1705: Assembly "TUnit.Mocks.Logging, Version=1.36.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c" uses "TUnit.Mocks, Version=1.36.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c" which has a higher version than referenced assembly "TUnit.Mocks" with identity "TUnit.Mocks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b8d4030011dbd70c".

Additional Context

Environment

  • .NET SDK: net8.0 / net9.0 / net10.0
  • Related packages:
    • TUnit
    • TUnit.AspNetCore
    • TUnit.Mocks
    • TUnit.Mocks.Http
    • TUnit.Mocks.Logging
    • TUnit.Mocks.Assertions

Notes

This appears to be a package versioning / dependency alignment issue. The consuming project resolves TUnit.Mocks to 1.0.0.0, while TUnit.Mocks.Http expects TUnit.Mocks 1.36.0.0.

It would be helpful if the package graph or published package metadata ensured consistent assembly versions across:

  • TUnit
  • TUnit.AspNetCore
  • TUnit.Mocks
  • TUnit.Mocks.Http
  • TUnit.Mocks.Logging
  • TUnit.Mocks.Assertions

Possible workaround

Align all TUnit-related packages to the same version and explicitly reference TUnit.Mocks in the test project.

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions