-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NSwag.MSBuild 11.4.3.0 throwing error about assembly Microsoft.AspNetCore.Mvc.ViewFeatures #905
Comments
Is the file "'Microsoft.AspNetCore.Mvc.ViewFeatures.dll" located in "$(SolutionDir)API\bin$(Configuration)"? Its important to first "dotnet publish" so that all required dlls are available in the output dir... |
Nope, but that doesn't seem to matter (unless I am completely missing something here). Its the NSwag.exe inside of ".nuget\packages\nswag.msbuild\11.4.3\build" that is missing "Microsoft.AspNetCore.Mvc.ViewFeatures" as well as the Mvc.Core.dll |
And yes, definitely doing a dotnet publish on the API project before trying to call NSwag on the API assembly. The spot where it is failing is on Here's the gist of the build event:
|
The msbuild package still runs in full .net 4.6.2 and maybe this fw is not able to load .net core 2.0 assemblies? Maybe we need a .net 4.7 or a .net core 2.0 version? Only the npm package is currently published with a .net core 2.0 version ("--core 2.0" switch) |
Can you create a repro of the problem? Btw: You should use a nswag.json file and just run "nswag.exe run nswag.json" - much simpler to manage the config. |
Sure, I'll create a sample project tonight or tomorrow and reply back here. Thank you for the tip about the json config, I'll definitely incorporate that. I'll keep you posted on the repro. |
https://github.com/jim-strang/nswag-issue905-sample Here's an example solution. Try building the API.Client project in Release mode and you will see the build errors. I tried to make it as simple as possible. Please let me know if there is anything else I can do to help out with this issue! |
Strange, why are the ASP.NET Core assemblies not in the publish folder? Where are they loaded from? Btw: NSwag also provides a middleware like Swashbuckle and Swagger UI, you don't need both :-) - and if the Swagger is generated in-process, you avoid all these problems - but you cant generate code during compilation... (ie the server must be running and serve the spec for the code generator) |
Right yeah - that makes sense, removing the Swashbuckle swagger gen is on my todo list. I want to have it done during the build so we can do c# and TS code gen based on the spec. I assume that the .NET Core assemblies are pulled from the dotnet SDK location? Maybe dotnet publish changed between 1.1 and 2.0 and there's some other flag needed to copy ALL assemblies to publish. I'll look into that. |
Ok, I've got one step further. If I add
to the .csproj, all required dlls are published. Now the assembly "netstandard" cannot be loaded... To avoid publishing all these DLLs, we have to find where these are installed on the PC and add this path to the ReferencePaths setting |
If I upgrade NSwagStudio to .NET 4.6.1 and install NETStandard.Library.NETFramework it works https://www.nuget.org/packages/NETStandard.Library.NETFramework/2.0.0-preview2-25405-01 But NETStandard.Library.NETFramework is deprecated :) |
Nice! Good find. How about the regular NETStandard.Library? |
Nope, doesn't work... only working with the prerelease version of NETStandard.Library.NETFramework... There must be something missing... |
Ref: dotnet/sdk#1220 Maybe NSwagStudio.csproj is using the old MSBuild tooling and this is why it is not working? |
If i run the .net core 2.0 nswag cmd line tool it also works (if the dlls are in the publish folder). |
Ill do some more tests tomorrow, already too late.. |
No worries, let me know if I can help out in any way |
Ok, I think I've found a solution. If you add
to your project (NSwagStudio, NSwag.Console), the loading works if the web app is published with
I've updated the wiki, but we should improve it... https://github.com/RSuter/NSwag/wiki/WebApiAssemblyToSwaggerGenerator#net-core |
I'm looking into ways to have something "pick up" the .net core assemblies without having to publish with Unless they should all be included with NSwag itself? Not sure |
Including with nswag is not an option because we would have to pick a specific version of asp.net - but nswag supports all versions of asp.net. This would force the users to always use the same asp.net version as nswag. |
Maybe this option can be set as dotnet publish cmd line param? Or you have to find the cache location and add this path to the ReferencePaths setting. |
Or maybe includes every assembly inside the |
Hi, C:_git\nswag-issue905-sample\API\bin\Release\PublishOutput Now error changed to a 4.6.1 version of another assembly: Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because the parent does not exist. I hope we can fix issue in order to run netcore 2 with swagger automation |
For me the latest code in master works ehen publishing all dlls... only problem is that the appveyor ci builds are no longer working. |
OK, now the CI build looks good... should we release so that you can really test this? |
Works with me, if you push out a new release I can test it on my end later today and report back |
NSwag.MSBuild 11.5.0 is looking good for me! |
It seems .msi is broken, I will wait for Rico fix. |
Fixed. |
Please report any problems. And we should update the wiki with tips how to load core assemblies: https://github.com/RSuter/NSwag/wiki/WebApiAssemblyToSwaggerGenerator#net-core Maybe we should create a new page for the dll loader alone. |
Hi, good news! I noticed that .msi is missing from the newest NSwag Build 868. I was testing at Windows and already uninstalled the previous version. Should I use now the command line? In this case, I need to double check documentation in order to start using .zip file. |
The latest MSI should be fine... |
Sorry, I am missing something. The .msi from NSwag v11.5.0 (Build 866) is broken. Should I replace the .exe/.dll files in the Program Files folder with newest from NSwag Build 868 .zip? |
Its fixed in v11.5.1, use this: https://github.com/RSuter/NSwag/releases/tag/NSwag-Build-868 |
Sorry again, there is no .msi installer there, only .zip and source code. |
Sorry, use this: http://rsuter.com/Projects/NSwagStudio/installer.php Will add tomorrow |
Great! Got it, error free now, 11.5.1 passed over the last error. I will keep testing. |
Working fine! Thank you. |
Created a new wiki page: https://github.com/RSuter/NSwag/wiki/Assembly-loading please update with your tips, findings, etc... |
updated with a link to the runtime catalog |
Recently upgraded my .NET Core 1.1 app to 2.0, and also updated the NSwag packages I was using. Calling NSwag.MSBuild inside of a pre-build event:
$(NSwagExe) webapi2swagger /assembly:"$(SolutionDir)API\bin\$(Configuration)\netcoreapp2.0\API.dll" /output:API.swagger.json
Produces the following error:
Anyone else having this issue with .NET Core 2.0?
The text was updated successfully, but these errors were encountered: