Bug Report Checklist
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
- Run the generation command above against any OpenAPI spec.
- Inspect the output directory — a src/My.Client.Test/ project is always generated.
- Note that the test .csproj contains hardcoded Version attributes on
<PackageReference> elements and is missing <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>.
- 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.
Bug Report Checklist
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" }Steps to reproduce
<PackageReference>elements and is missing<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>.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.