Skip to content

Conversation

noormahdi
Copy link

When the project path has a space, the build fails while trying to run config.nswag

Here is the error I was facing before fixing it by adding quotes around project directory path in the Web.csproj file

error:

1>NSwag command line tool for .NET Core Net90, toolchain v14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0))
1>Visit http://NSwag.org for more information.
1>NSwag bin directory: C:\Users\Noor.nuget\packages\nswag.msbuild\14.2.0\tools\Net90
1>
1>Executing file 'config.nswag' with variables 'Configuration=Debug'...
1>E:\Noor\Code\Directory With Space\WeatherApp\src\Web\Web.csproj : warning MSB4057: The target "__GetNSwagProjectMetadata" does not exist in the project.
1>System.InvalidOperationException: Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project.If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.
1> at NSwag.Commands.Generation.AspNetCore.ProjectMetadata.ReadUsingMsBuildTargets(List`1 args, String file, String buildExtensionsDir, IConsoleHost console) in //src/NSwag.Commands/Commands/Generation/AspNetCore/ProjectMetadata.cs:line 160
1> at NSwag.Commands.Generation.AspNetCore.ProjectMetadata.GetProjectMetadata(String file, String buildExtensionsDir, String framework, String configuration, String runtime, Boolean noBuild, String outputPath, IConsoleHost console) in /
/src/NSwag.Commands/Commands/Generation/AspNetCore/ProjectMetadata.cs:line 92
1> at NSwag.Commands.Generation.AspNetCore.AspNetCoreToOpenApiCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in //src/NSwag.Commands/Commands/Generation/AspNetCore/AspNetCoreToOpenApiCommand.cs:line 70
1> at NSwag.Commands.NSwagDocumentBase.GenerateSwaggerDocumentAsync() in /
/src/NSwag.Commands/NSwagDocumentBase.cs:line 270
1> at NSwag.Commands.NSwagDocument.ExecuteAsync() in //src/NSwag.Commands/NSwagDocument.cs:line 67
1> at NSwag.Commands.Document.ExecuteDocumentCommand.ExecuteDocumentAsync(IConsoleHost host, String filePath) in /
/src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs:line 76
1> at NSwag.Commands.Document.ExecuteDocumentCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in //src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs:line 33
1> at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
1> at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
1> at NSwag.Commands.NSwagCommandProcessor.ProcessAsync(String[] args) in /
/src/NSwag.Commands/NSwagCommandProcessor.cs:line 65

@noormahdi noormahdi closed this Aug 10, 2025
@noormahdi noormahdi reopened this Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant