Skip to content
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

new version generates builderror #1576

Closed
roscoedeemarutam opened this issue Sep 5, 2018 · 39 comments
Closed

new version generates builderror #1576

roscoedeemarutam opened this issue Sep 5, 2018 · 39 comments

Comments

@roscoedeemarutam
Copy link

roscoedeemarutam commented Sep 5, 2018

hi,

I just installed the new version of nswagstudio and without doing anything i get this error.

tonsoft.Json.JsonSerializationException: Error setting value to 'SelectedSwaggerGeneratorRaw' on 'NSwag.Commands.NSwagDocument'. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Abstractions, Version=1.0.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
Check if .NET Core is installed and 'dotnet' is globally available.

I'm not using .net core.
please advise.

my nswag file:

{
"runtime": "Default",
"defaultVariables": null,
"swaggerGenerator": {
"webApiToSwagger": {
"controllerNames": [
"Euromex.Web.Controller.Webconsultatie.DocumentWebConsultatieController",
"Euromex.Web.Controller.Webconsultatie.DossierWebConsultatieController",
"Euromex.Web.Controller.Webconsultatie.MakelaarWebConsultatieController"
],
"isAspNetCore": false,
"defaultUrlTemplate": "api/{controller}/{id?}",
"addMissingPathParameters": false,
"defaultPropertyNameHandling": "CamelCase",
"defaultReferenceTypeNullHandling": "Null",
"defaultEnumHandling": "Integer",
"flattenInheritanceHierarchy": false,
"generateKnownTypes": false,
"generateXmlObjects": false,
"generateAbstractProperties": false,
"ignoreObsoleteProperties": false,
"allowReferencesWithProperties": true,
"excludedTypeNames": [],
"serviceHost": null,
"serviceBasePath": null,
"serviceSchemes": [],
"infoTitle": "DocumentWebConsultatieController",
"infoDescription": "The Document controller for the Web consultation app",
"infoVersion": "1.0.0",
"includedVersions": null,
"documentTemplate": null,
"documentProcessorTypes": [],
"operationProcessorTypes": [],
"typeNameGeneratorType": null,
"schemaNameGeneratorType": null,
"contractResolverType": null,
"serializerSettingsType": null,
"output": "../Content/Swagger specs/DocumentWebConsultatieControllerSpec.json",
"outputType": "Swagger2",
"assemblyPaths": [
"../bin/Euromex.Web.dll"
],
"assemblyConfig": "../Web.config",
"referencePaths": []
}
},
"codeGenerators": {
"swaggerToTypeScriptClient": {
"className": "{controller}Service",
"moduleName": "",
"namespace": "",
"typeScriptVersion": 2.7,
"template": "Angular",
"promiseType": "Promise",
"httpClass": "HttpClient",
"useSingletonProvider": true,
"injectionTokenType": "InjectionToken",
"rxJsVersion": 6.0,
"dateTimeType": "String",
"nullValue": "Undefined",
"generateClientClasses": true,
"generateClientInterfaces": false,
"generateOptionalParameters": true,
"exportTypes": true,
"wrapDtoExceptions": false,
"clientBaseClass": "",
"wrapResponses": false,
"wrapResponseMethods": [],
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"protectedMethods": [],
"configurationClass": "",
"useTransformOptionsMethod": false,
"useTransformResultMethod": false,
"generateDtoTypes": true,
"operationGenerationMode": "MultipleClientsFromOperationId",
"markOptionalProperties": true,
"generateCloneMethod": false,
"typeStyle": "Class",
"classTypes": [],
"extendedClasses": [],
"extensionCode": null,
"generateDefaultValues": true,
"excludedTypeNames": [],
"handleReferences": false,
"generateConstructorInterface": true,
"convertConstructorInterfaceData": false,
"importRequiredTypes": true,
"useGetBaseUrlMethod": false,
"baseUrlTokenName": "API_BASE_URL",
"queryNullValue": "",
"templateDirectory": null,
"typeNameGeneratorType": null,
"propertyNameGeneratorType": null,
"enumNameGeneratorType": null,
"serviceHost": null,
"serviceSchemes": null,
"output": "../../Euromex.WebConsultatie/src/app/services/Generated/WebConsultatie.WebApi.Generated.Service.ts"
}
}
}

@RicoSuter
Copy link
Owner

can you try with the new UseNuGetCache setting?

image

@RicoSuter
Copy link
Owner

And/or can you provide a sample project?

@roscoedeemarutam
Copy link
Author

hi, To be honest providing a sample project is very difficult because when i do it from scratch it works. I'm working on a very big project and was finally able to get everything working last week and it was working brilliantly until i do this update now :(
Adding the local nuget cache folder doesn't work!! as far as i understand its missing 'Microsoft.AspNetCore.Hosting.Abstractions' and I'm not using .net core??

@roscoedeemarutam
Copy link
Author

is there a way to downgrade and install the version I had again?

@RicoSuter
Copy link
Owner

Sure, just reinstall v11.18.7... but i'd really like to fix this assembly loading problem. However I am getting crazy with all these assembly loading problems all the time...

@roscoedeemarutam
Copy link
Author

I understand... but at the moment I'm not able to spend much time looking. :(
I'm on a very tight deadline, so I just need a working version momentarily.

@Zaismussen
Copy link

I'm having the same problem with every regular .Net Framework project I try to generate from. I'm attaching an example that manifests the error for me. The nswag file I used in NSwagStudio is in the root of the project folder.

SwaggerErrorTest.zip

@RicoSuter
Copy link
Owner

Ok thanks will look into this soon, just stay on the old version until we have a fix

@Zaismussen
Copy link

I don't seem to have a copy of the old version, and haven't been able to find a link to it. Where can I get it?

@ghost
Copy link

ghost commented Sep 6, 2018

@Zaismussen, if you use chocolatey:

choco install nswagstudio --version 11.18.7

Chocolately can be downloaded by following these instructions: https://chocolatey.org/install

@RicoSuter
Copy link
Owner

Hmm, it works for me, even without the NuGet cache option:

image

@Zaismussen
Copy link

Let me know if there's anything I can do to help figure it out. I will probably have some time today and tomorrow to mess around with it, and I can probably survive a few days before downgrading if necessary.

@RicoSuter
Copy link
Owner

We really need a sample where we can repro this and which i can add to the test suite to avoid regressions in the future

@RicoSuter
Copy link
Owner

Adding the local nuget cache folder doesn't work!! as far as i understand its missing 'Microsoft.AspNetCore.Hosting.Abstractions' and I'm not using .net core??

The generator has a dependency on core but it should work without that...

@xinyuewu
Copy link

Hi guys, I'm having exactly the same issue. Where can I get a microsoft installer for version 11.18.* or below? All installers I've found so far are the latest (11.19.0)

@RicoSuter
Copy link
Owner

In the github releases page you can find all old installers

@xinyuewu
Copy link

In the github releases page you can find all old installers

Got it! Thank you very much!

@zengouu
Copy link

zengouu commented Oct 4, 2018

Just updated to 11.20.1.0 and this issue still persists. Regular (non-Core) .NET Framework Web Api project.

Referenced assemblies are search from:
C:\Program Files\dotnet\sdk\NuGetFallbackFolder
%USERPROFILE%/.nuget/packages

And also have the setting "Add local Nuget's cache folder to reference paths" enabled.

@MaximBalaganskiy
Copy link

MaximBalaganskiy commented Oct 24, 2018

I observe the same upgrading from 11.17.19 to 11.20.1.
I noticed that the latest npm nswag version uses Microsoft.AspNetCore.Hosting.Abstractions.dll 1.0.5.31018 of 26/10/85 as opposed to the older version which uses Microsoft.AspNetCore.Hosting.Abstractions.dll 1.1.3.30908 of 09/09/17. I am pretty sure this is what's causing the exception - older DLLs got into the bundle

@RicoSuter
Copy link
Owner

Did you try using a newer runtime, eg NetCore21?

@MaximBalaganskiy
Copy link

MaximBalaganskiy commented Oct 24, 2018 via email

@RicoSuter
Copy link
Owner

I think we should change the dependency of the full .NET package to ASP.NET Core 2.0 then... the older libraries are no longer supported anyway...

@RicoSuter RicoSuter added this to the vNext milestone Oct 24, 2018
@MaximBalaganskiy
Copy link

Why not change the dependency to what it used to be in older versions? Those worked just fine.

@roscoedeemarutam
Copy link
Author

just for the record. I had to change computer and with reinstalling everything. the latest version of nswagstudio is working perfectly!

@MirKml
Copy link

MirKml commented Nov 1, 2018

If I need to generate typescript from full .net 4.7 assembly, issue is still presented. I have also installed .net core 21. Change the runtime to NetCore21 doesn't help.

@RicoSuter
Copy link
Owner

@MirKml is the problem the spec generation or typescript generation?

@MirKml
Copy link

MirKml commented Nov 1, 2018

@RSuter Hm, this is little bit weird. When I upgraded from 11.18.7 via built in upgrading process to 11.20.1 then after newly upgraded nswag studio is started, I want to generate Typescript from .net 4.7 assembly, nswag crashes with the

Newtonsoft.Json.JsonSerializationException: Error setting value to 'SelectedSwaggerGeneratorRaw' on 'NSwag.Commands.NSwagDocument'. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Abstractions, Version=1.0.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
Check if .NET Core is installed and 'dotnet' is globally available.
Runtime: Default

After change runtime to NetCore21 and trying to do same thing, error is

TypeLoadException: Could not load type 'System.Web.UI.Page' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Try running the document in another runtime, e.g. /runtime:NetCore20
Runtime: NetCore21

It makes sense, I cannot load .net 4.7 assembly when netcore21 runtime is used.

But when I download latest zip package from the http://rsuter.com/Projects/NSwagStudio/archive.php. Everything works fine. Maybe also with the uninstall and install via msi, but I didn't test. So maybe bug is somewhere in the MSI, upgrade process or something like that.

@MirKml
Copy link

MirKml commented Nov 1, 2018

Uninstall and install new version also works. So problem is definitely somewhere in upgrading process from 11.18.7 to newer version. But uninstall and install is reasonable workaround. So I think it can be closed.

@MaximBalaganskiy
Copy link

MaximBalaganskiy commented Nov 1, 2018 via email

@RicoSuter
Copy link
Owner

Yes? This is really strange as all binaries should be replaced, etc.

@RicoSuter
Copy link
Owner

You’renot using one of the ci build artifacts with the same version as the current released one?

@MaximBalaganskiy
Copy link

MaximBalaganskiy commented Nov 1, 2018 via email

@RicoSuter
Copy link
Owner

But the version in the generated artifacts is correct?

@MaximBalaganskiy
Copy link

MaximBalaganskiy commented Nov 1, 2018 via email

@RicoSuter
Copy link
Owner

Yes, but the version in the generated spec or code is correct?

@MaximBalaganskiy
Copy link

MaximBalaganskiy commented Nov 1, 2018 via email

@RicoSuter
Copy link
Owner

It seems that I had problems publishing to NPM in the v11.20.1 release so I had to manually release it - I think that an old version or something must have slipped in there... will investigate. A new version will be released in the next days anyway...

@juveilko
Copy link

juveilko commented Nov 2, 2018

When running latest version 11.20.1.0 from command line in windows environment, it crashed because of missing dlls. I worked around this issue by copying the missing dll from the "NSwagStudio" folder into the Win sub-folder as I kept encountering them. Eventually, I managed to run Nswag successfully.

If I recall correctly the dlls I copied were Microsoft.AspNetCore.:

  • Hosting.Abstractions
  • Hosting.Server.Abstractions
  • Http.Features
  • TestHost

I am not 100% sure those were all.

@jepperaskdk
Copy link

@RicoSuter I'm getting this error after trying to upgrade to .NET 8.0, using version 14.0.0-preview012. In nswag.json I set "runtime": "Net80".

From this command:
dotnet "C:\Users\USER.nuget\packages\nswag.msbuild\14.0.0-preview012\buildTransitive../tools/Net80/dotnet-nswag.dll" run nswag.json

Newtonsoft.Json.JsonSerializationException: Error setting value to 'SelectedSwaggerGeneratorRaw' on 'NSwag.Commands.NSwagDocument'.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at NSwag.Commands.NSwagDocumentBase.set_SelectedSwaggerGeneratorRaw(JObject value) in /_/src/NSwag.Commands/NSwagDocumentBase.cs:line 88
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.SetValue(Object target, Object value)
   --- End of inner exception stack trace ---

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants