user2255428
user2255428

Reputation: 61

ASP.NET Core error on building with NSwag Error MSB3073

When I build the application, I get the following error message

The command "dotnet "C:\Users\Adminuser\.nuget\packages\nswag.msbuild\13.0.6\build\../tools/NetCore22/dotnet-nswag.dll" run /variables:Configuration=Debug" exited with code
-2147450730.    Northwind.WebUI C:\Users\Adminuser\Documents\Visual Studio 2017\Projects\NorthwindTraders-master\Northwind.WebUI\Northwind.WebUI.csproj 60

Any Idea how to fix this issue?

Upvotes: 4

Views: 18838

Answers (4)

Eren Uğur
Eren Uğur

Reputation: 21

A tip for will see this post later: Open cmd and go inside your project. If you write the error you you can see your error in cmd in more detail. For example :
dotnet C:\Users\Adminuser\.nuget\packages\nswag.msbuild\13.0.6\build\../tools/NetCore22/dotnet-nswag.dll" run nswag.json /variables:Configuration=Debug --verbose

The reason why I am getting this error is in the nswag.json file "isAspNetCore": true because the line is missing.

Upvotes: 1

Rafael Neto
Rafael Neto

Reputation: 1290

NSwag fails when two methods of the same controller share the same HTTP GET (or HTTP POST) verb without setting an explicit Route in one of them:

public class TestController : ControllerBase
{
    [HttpGet]
    public async Task<ActionResult<int>> Test1()
    {
        return await Task.FromResult(1);
    }

    [HttpGet]
    [Route("Test2")] // <-----< This line is important! <-----<
    public async Task<ActionResult<int>> Test2()
    {
        return await Task.FromResult(2);
    }
}

Without the [Route("Test2")] line, I get a System.InvalidOperationException: The method 'get' on path '/api/Test' is registered multiple times. error.

Upvotes: 2

sinetemba
sinetemba

Reputation: 63

Swagger doesn't like it when two or more endpoints in the same Controller share the same name. make use of routing attributes and make sure they are unique.

Upvotes: 5

Guillaume Cornez
Guillaume Cornez

Reputation: 1

Try to install NSwagStudio then re open your visual studio. That's should solve your problem.

If it's still not working

give a look about your output console when you try to compile your project, you should see something like this

1>Executing file 'nswag.json' with variables 'Configuration=Debug'... 1>Launcher directory: C:\Users\Shadow.nuget\packages\nswag.msbuild\13.1.6\tools\NetCore30

You should have a file called dotnet-nswag.exe in your c:\user...\tools\netcore30 directory.

Put this exe in your environnement path.

Re open visual studio and your error should be gone.

Upvotes: 0

Related Questions