NSwag build error – Project file does not exist / Unable to retrieve project metadata

N

While working on a project that used NSwag, when the solution was built, Visual Studio (and dotnet build from the command line) reported the following error:

Pretty frustrating, as it wasn’t clear what the error meant.
This project used NSwag.MSBuild to generate the client on build.

As per their documentation, we had an after build target:

The problem here was that it wasn’t taking in to account that my directory had a space in it:
`C:\Users\Alex Brown\my-project`

Changing the target to add quotes around the path fixed the issue:
This is done by using `"` as seen below: