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

System.ArgumentException: Absolute path information is required #2515

Open MisinformedDNA opened 5 years ago

MisinformedDNA commented 5 years ago

Getting this error when trying to generate OpenAPI spec (eventuallly to create a C# client):

C:\Users\50587.nuget\packages\nswag.msbuild\13.1.3\tools\NetCore30> dotnet dotnet-nswag.dll aspnetcore2openapi /assembly:$binFolder\$projectName.dll /documentNamNSwag command line tool for .NET Core NetCore30, toolchain v13.1.3.0 (NJsonSchema v10.0.27.0 (Newtonsoft.Json v12.0.0.0)) Visit http://NSwag.org for more information. NSwag bin directory: C:\Users\50587.nuget\packages\nswag.msbuild\13.1.3\tools\NetCore30 System.ArgumentException: Absolute path information is required. (Parameter 'assemblyPath') at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath) at NSwag.Commands.IsolatedSwaggerOutputCommandBase1.<>c__DisplayClass10_0.<LoadAssemblies>b__0(String path) in C:\projects\nswag\src\NSwag.Commands\Commands\IsolatedSwaggerOutputCommandBase.cs:line 61 at System.Linq.Enumerable.SelectEnumerableIterator2.ToArray() at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at NSwag.Commands.IsolatedSwaggerOutputCommandBase1.LoadAssemblies(IEnumerable1 assemblyPaths, AssemblyLoader assemblyLoader) in C:\projects\nswag\src\NSwag.Commands\Commands\IsolatedSwaggerOutputCommandBase.cs:line 60 at NSwag.Commands.Generation.OpenApiGeneratorCommandBase1.CreateWebHostAsync(AssemblyLoader assemblyLoader) in C:\projects\nswag\src\NSwag.Commands\Commands\Generation\OpenApiGeneratorCommandBase.cs:line 330 at NSwag.Commands.Generation.AspNetCore.AspNetCoreToSwaggerCommand.RunIsolatedAsync(AssemblyLoader assemblyLoader) in C:\projects\nswag\src\NSwag.Commands\Commands\Generation\AspNetCore\AspNetCoreToOpenApiCommand.cs:line 310 at NSwag.Commands.IsolatedCommandBase1.IsolatedCommandAssemblyLoader1.Run(String commandType, String commandData, String[] assemblyPaths, String[] referencePaths) in C:\projects\nswag\src\NSwag.Commands\Commands\IsolatedCommandBase.cs:line 76 at NSwag.Commands.IsolatedCommandBase1.<>c__DisplayClass17_0.<RunIsolatedAsync>b__0() in C:\projects\nswag\src\NSwag.Commands\Commands\IsolatedCommandBase.cs:line 61 at System.Threading.Tasks.Task1.InnerInvoke() at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj) at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location where exception was thrown --- at NSwag.Commands.IsolatedCommandBase1.RunIsolatedAsync(String configurationFile) in C:\projects\nswag\src\NSwag.Commands\Commands\IsolatedCommandBase.cs:line 61 at NSwag.Commands.IsolatedSwaggerOutputCommandBase1.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\IsolatedSwaggerOutputCommandBase.cs:line 47 at NSwag.Commands.Generation.AspNetCore.AspNetCoreToSwaggerCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\Generation\AspNetCore\AspNetCoreToOpenApiCommand.cs:line 95 at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input) at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input) at NConsole.CommandLineProcessor.Process(String[] args, Object input) at NSwag.Commands.NSwagCommandProcessor.Process(String[] args) in C:\projects\nswag\src\NSwag.Commands\NSwagCommandProcessor.cs:line 56

And here's part of my project file:

<Project Sdk="Microsoft.NET.Sdk.Web">
 <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>
 <ItemGroup>
    <PackageReference Include="NSwag.AspNetCore" Version="13.1.3" />
    <PackageReference Include="NSwag.MSBuild" Version="13.1.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>
</Project>

Publish was previously done with dotnet publish /p:CopyLocalLockFileAssemblies=true

What am I missing?

RicoSuter commented 5 years ago

This

/assembly:$binFolder$projectName.dll 

probably is the problem

MisinformedDNA commented 5 years ago

Can you be more specific? It resolves to my main DLL, so what could be wrong with it?

RicoSuter commented 4 years ago

Instead of /assembly:... you should use /project:...csproj