OpenAPITools / OpenAPITools/openapi-generator

[BUG] Errors when running `nuget pack`

Open
#5,520 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: C-Sharp Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Got the following errors when running nuget pack -Build -OutputDirectory out src/Open.Petstore/Open.Petstore.csproj (package name set to Open.Petstore)

  Model/Order.cs(37,10): error CS0246: The type or namespace name 'JsonConverterAttribute' could not be found (are you missing a using directive or an assembly reference?) [/private/tmp/Code/csharp/openapi_client/src/Open.Petstore/Open.Petstore.csproj]
  Model/Order.cs(37,10): error CS0246: The type or namespace name 'JsonConverter' could not be found (are you missing a using directive or an assembly reference?) [/private/tmp/Code/csharp/openapi_client/src/Open.Petstore/Open.Petstore.csproj]
  Model/Order.cs(37,31): error CS0246: The type or namespace name 'StringEnumConverter' could not be found (are you missing a using directive or an assembly reference?) [/private/tmp/Code/csharp/openapi_client/src/Open.Petstore/Open.Petstore.csproj]
  Model/Pet.cs(69,10): error CS0246: The type or namespace name 'JsonConstructorAttributeAttribute' could not be found (are you missing a using directive or an assembly reference?) [/private/tmp/Code/csharp/openapi_client/src/Open.Petstore/Open.Petstore.csproj]
  Model/Pet.cs(69,10): error CS0246: The type or namespace name 'JsonConstructorAttribute' could not be found (are you missing a using directive or an assembly reference?) [/private/tmp/Code/csharp/openapi_client/src/Open.Petstore/Open.Petstore.csproj]
  Client/OpenAPIDateConverter.cs(19,41): error CS0246: The type or namespace name 'IsoDateTimeConverter' could not be found (are you missing a using directive or an assembly reference?) [/private/tmp/Code/csharp/openapi_client/src/Open.Petstore/Open.Petstore.csproj]
  Client/ExceptionFactory.cs(23,67): error CS0246: The type or namespace name 'IRestResponse' could not be found (are you missing a using directive or an assembly reference?) [/private/tmp/Code/csharp/openapi_client/src/Open.Petstore/Open.Petstore.csproj]
  Model/Pet.cs(37,10): error CS0246: The type or namespace name 'JsonConverterAttribute' could not be found (are you missing a using directive or an assembly reference?) [/private/tmp/Code/csharp/openapi_client/src/Open.Petstore/Open.Petstore.csproj]
  Model/Pet.cs(37,10): error CS0246: The type or namespace name 'JsonConverter' could not be found (are you missing a using directive or an assembly reference?) [/private/tmp/Code/csharp/openapi_client/src/Open.Petstore/Open.Petstore.csproj]
  Model/Pet.cs(37,31): error CS0246: The type or namespace name 'StringEnumConverter' could not be found (are you missing a using directive or an assembly reference?) [/private/tmp/Code/csharp/openapi_client/src/Open.Petstore/Open.Petstore.csproj]

    3 Warning(s)
    44 Error(s)

Time Elapsed 00:00:05.19
Error NU5013: Failed to build 'Open.Petstore.csproj'.
openapi-generator version

Latest master

OpenAPI declaration file content or url

Pestore spec (OAS 2.0)

Command line used for generation
nuget pack -Build -OutputDirectory out src/Open.Petstore/Open.Petstore.csproj

A workaround is to use nuget pack src/Open.Petstore/Open.Petstore.nuspec instead.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with nuget pack -Build -OutputDirectory out src/Open.Petstore/Open.Petstore.csproj and compare it with packing src/Open.Petstore/Open.Petstore.nuspec. Inspect the generated Open.Petstore.csproj, Model/*.cs, Client/OpenAPIDateConverter.cs, and Client/ExceptionFactory.cs; done means the project builds and packages without the reported missing-type errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.