Skip to content

OpenAPIReference does not work for SDK generators that create C# output in a folder #38547

Closed
@darrelmiller

Description

@darrelmiller

Describe the bug

The following build action is executed when you use a SDK generator that uses OutputPath to place the generated C# files.

      <Compile Include="@(_Directories -> '%(Identity)/**/*.$(DefaultLanguageSourceExtension)')"
          Exclude="@(Compile)"
          Condition="'$(DefaultLanguageSourceExtension)' != '.ts'">
        <SourceDocument>%(_Directories.FullPath)</SourceDocument>
      </Compile>

<Compile Include="@(_Directories -> '%(Identity)/**/*.$(DefaultLanguageSourceExtension)')"

This outputs a CSC command that includes the globbed path as a parameter. From my tests CSC doesn't appear to support path globbing.

To Reproduce

Add an OutputPath value to the OpenAPIReference in the csproj file. Unfortunately I think NSwag fails with this setting so it isn't as easy to see the final error. You first need to fix the NSwag .targets file. I can provide full steps to repro using kiota as a SDK generator if needed.

Exceptions (if any)

This produces the following error at build time.

CSC : error CS2021: File name 'obj\sdk/**/*..cs' is empty, contains invalid characters, has a drive specification without an absolute path, or is too long

I think the extra dot is a problem too, but even after removing that, the globbing is still a problem.

Further technical details

I tried this on .net 5 and 6. Same error.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions