Skip to content

[BUG][csharp] Client test projects are generated without ManagePackageVersionsCentrally override #23090

@wturk

Description

@wturk

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating a C# client using the csharp generator, a test project is always generated alongside the main client project. There is no configuration option to skip generation of the test project.
This is problematic for projects that use Central Package Management (CPM) in their repository. The generated test project includes hardcoded Version attributes on elements and does not include false in its , causing build failures in repositories that enforce CPM. While the main client project is configured to handle this, there is no equivalent mechanism for the test project since it cannot be skipped.

openapi-generator version

7.16.0

OpenAPI declaration file content or url

Any valid OpenAPI spec reproduces this, e.g. the petstore:
https://petstore3.swagger.io/api/v3/openapi.json

Generation Details

Generation Details

{
  "packageName": "My.Client",
  "targetFramework": "net10.0"
}
openapi-generator-cli generate \
  --input-spec https://petstore3.swagger.io/api/v3/openapi.json \
  --generator-name csharp \
  --output ./output
Steps to reproduce
  1. Run the generation command above against any OpenAPI spec.
  2. Inspect the output directory — a src/My.Client.Test/ project is always generated.
  3. Note that the test .csproj contains hardcoded Version attributes on <PackageReference> elements and is missing <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>.
  4. Attempt to build in a repository with Central Package Management enabled — build fails
Related issues/PRs

Not found.

Suggest a fix

The main client .csproj template already includes <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally> in its <PropertyGroup> to support repositories using Central Package Management (CPM). The test project .csproj template should be updated in the same way, adding the same property so that the generated test project is consistent with the main client project and does not break CPM-enforced repositories.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions