Nswag: MSBuild: How to generate C# classes so they would be visible by the compiler?

Created on 12 Aug 2019  路  4Comments  路  Source: RicoSuter/NSwag

When I generate C# classes with NSwag via MSBuild
(following this wiki: https://github.com/RicoSuter/NSwag/wiki/MSBuild),
the code is generated. But for the first time I make the build (when there are no generated classes yet), I get an error that compiler cannot see those classes. As I have the references in code to the generated classes.
Do you have any idea on how to change the MSBuild script to make it see the newly generated classes?

Most helpful comment

All 4 comments

For a fully worked example with NSwag and MSBuild, I wrote a post here that could be of interest: https://stu.dev/generating-typed-client-for-httpclientfactory-with-nswag/

@KrzysztofKielce mate you saved my day. What I still don't understand is how come that it's absent from the official documentation? It simply doesn't work without your "workaround".

I am happy to help! You can vote me up on stack overflow, if you want.
Did you try Slang's solution? Does it work for you? It seems less hacky.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akamyshanov picture akamyshanov  路  4Comments

blackbaud-GavinNicol picture blackbaud-GavinNicol  路  3Comments

alanedwardes picture alanedwardes  路  3Comments

RawsomeGH picture RawsomeGH  路  4Comments

Zshazz picture Zshazz  路  4Comments