question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assembly parameter value for nswag aspnetcore2swagger command

See original GitHub issue

I’m trying to use latest version of nswag (11.18.7 at the moment) from msbuild in asp.net core project (netcoreapp2.1) and aspnetcore2swagger command just doesn’t work. Error is always System.IO.FileNotFoundException no matter if I use full assembly path, relative path from project folder or just assembly name. I’m using it the way it is recommended in the documentation for .NET Core projects:

  <Target Name="NSwag" AfterTargets="Build">
    <Copy SourceFiles="@(ReferencePath)" DestinationFolder="$(OutDir)References" />
    <Message Importance="high" Text="Run '$(NSwagExe_Core21) aspnetcore2swagger /assembly:$(OutDir)$(AssemblyName).dll'" />
    <Exec Command="$(NSwagExe_Core21) aspnetcore2swagger /assembly:$(OutDir)$(AssemblyName).dll" />
    <RemoveDir Directories="$(OutDir)References" />
  </Target>

If I just replace aspnetcore2swagger command with webapi2swagger without making any other changes - it works perfectly.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:19 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
stijnherremancommented, Jun 24, 2019

I’ve tried debugging this issue, but I got stuck at IsolatedCommandBase.RunIsolatedAsync, unable to step into the Task.Run code.

But I also found a satisfactory workaround by using $(OutDir) to set the working directory instead of passing it to /assembly::

<Exec Command="$(NSwagExe_Core21) aspnetcore2swagger /assembly:$(TargetFileName) /output:build-artifacts/swagger.json" WorkingDirectory="$(OutDir)" />
1reaction
RicoSutercommented, Sep 5, 2018
  • you shouldnt use webapi2swagger as this generator will not be supported eventually… we need to get aspnetcore2swagger running in all scenarios… please try aspnetcore2swagger with a project (and not assembly) + nobuild true when running from csproj
Read more comments on GitHub >

github_iconTop Results From Across the Web

Get started with NSwag and ASP.NET Core
Package installation · Right-click the project in Solution Explorer > Manage NuGet Packages · Set the Package source to "nuget.org" · Enter "NSwag....
Read more >
swagger - Best practices for using NSwag ...
I've been using NSwag for a while to generate an Angular TS client to ... Command="$(NSwagExe_Core21) webapi2swagger /assembly:$(OutDir)RR.
Read more >
asp.net core - Why do NSwag fail on my computer and not ...
NSwag is looking for the program class in the assembly you want's to create a proxyclient for. It does that by refelction and...
Read more >
Executing CLI Tools
Executing CLI Tools. Interacting with third-party command-line interface tools (CLIs) is an essential task in build automation.
Read more >
Using OpenApiReference To Generate Open API Client ...
I have been using Rico Suter's brilliant NSwag for some time now to generate client code for working with HTTP API endpoints.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found