RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.78k stars 1.29k forks source link

NSwag.ConsoleCore package does not include dependent assemblies #1314

Open richardgavel opened 6 years ago

richardgavel commented 6 years ago

Is this a package that is meant to allow people to run the NSwag console or include it in another project? I'm assuming the former, in which case the dependent assemblies should be contained within the package, not require getting any dependencies? If the latter, can we have a package that is meant for getting the binaries for execution, in the vein of the NuGet.CommandLine package?

RicoSuter commented 6 years ago

You can install this package (NSwag.ConsoleCore) and run the tool with dotnet nswag ... in the project directory... Not sure if it actually works :-)

There is also the NSwag.MSBuild package which can also be installed in your project and then used in a csproj/msbuild task.

What exactly do you want to accomplish?

richardgavel commented 6 years ago

No, it doesn't work, because the DLL is missing all it's dependencies, unless you get all the dependent packages and consolidate them into a single directory. I want to call the command line from Cake without having to depend on nswag being prior installed, so I want to pull the exeutable via nuget. this is a common pattern from cake, downloaded needed external tools from a nuget package.

i know there is a cake package, but it's old.

AlexanderButs commented 6 years ago

I tried to do the same thing but unfortunately couldn't. I thought this is me the cause :), but now I guess it's not. Would be nice to have it works properly. Learnt Cake.NSwag code but NSwag command line call is commented there.

richardgavel commented 6 years ago

One suggestion, another practice in cases like this is to ILMerge the assemblies into a combined EXE. Not as big a deal, but a thought.

AlexanderButs commented 6 years ago

I had an idea to use TestHost (which is usually used for integration testing) for inprocess hosting web api and call swagger api via real http call to get necessary data. Should work I guess.

RicoSuter commented 6 years ago

If it's hosted as middleware then test server is not needed, but when running the new generator via CLI, usage of TestServer is a good idea, PR: https://github.com/RSuter/NSwag/pull/1343

RicoSuter commented 6 years ago

Why is it working here? https://github.com/RSuter/NSwag/issues/1157

AlexanderButs commented 6 years ago

C:\Work\TicTacToe\src\TicTacToe   master  λ dotnet nswag aspnetcore2swagger /project:TicTacToe.csproj /output:testing.json NSwag command line tool for .NET Core NetCore21, toolchain v11.17.12.0 (NJsonSchema v9.10.50.0 (Newtonsoft.Json v9.0.0.0)) Visit http://NSwag.org for more information. NSwag bin directory: C:\Users\Alexander\.nuget\packages\nswag.consolecore\11.17.12\lib\netcoreapp2.1 System.InvalidOperationException: Unable to locate NSwag.AspNetCore.Launcher.dll in C:\Users\Alexander\.nuget\packages\.tools\nswag.consolecore\11.17.12\netcoreapp2.1. at NSwag.Commands.SwaggerGeneration.AspNetCore.AspNetCoreToSwaggerCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input) in C:\projects\nconsole\src\NConsole\CommandLineProcessor.cs:line 139 at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input) in C:\projects\nconsole\src\NConsole\CommandLineProcessor.cs:line 107 at NConsole.CommandLineProcessor.Process(String[] args, Object input) in C:\projects\nconsole\src\NConsole\CommandLineProcessor.cs:line 158 at NSwag.Commands.NSwagCommandProcessor.Process(String[] args)