microsoft / OpenAPI.NET.CSharpAnnotations

Generates OpenAPI Document from C# Annotations
MIT License
195 stars 35 forks source link

Newtonsoft.Json failing to load in ADO build task #202

Open ghost opened 5 years ago

ghost commented 5 years ago

Hi,

I have been attempting to add an OpenAPI build task to my Azure DevOps pipeline, but am currently stuck on receiving an error whenever I attempt to build my document:

ExceptionType: FileLoadException || Message: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
    GET /api/v1/xxx || ExceptionType: AddingSchemaReferenceFailedException || Message: Adding schema "xxx.ValidationError" to the schema reference registry failed with the error: Adding schema "System.Collections.Generic.List_xxx.ApiError_" to the schema reference registry failed with the error: Adding schema "xxx.ApiError" to the schema reference registry failed with the error: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)...

I'm not sure how this error is arising - I've imported the same version of Newtonsoft.Json via NuGet in every project in my solution, and I import all .dll dependencies from the same dotnet build task (project info redacted):

Found: "C:\vsts-agent-win-x64-2.144.0\_work\4\s\xxx\xxx.xml"
Searching for pattern "xxx\bin\Release\**\publish\xxx*.dll" under "C:\vsts-agent-win-x64-2.144.0\_work\4\s" path.
Found: "C:\vsts-agent-win-x64-2.144.0\_work\4\s\xxx\bin\Release\netcoreapp2.2\publish\xxx1.dll", "C:\vsts-agent-win-x64-2.144.0\_work\4\s\xxx\bin\Release\netcoreapp2.2\publish\xxx2.dll", "C:\vsts-agent-win-x64-2.144.0\_work\4\s\xxx\bin\Release\netcoreapp2.2\publish\xxx3.dll", "C:\vsts-agent-win-x64-2.144.0\_work\4\s\xxx\bin\Release\netcoreapp2.2\publish\xxx4.dll"
Searching for pattern "xxx\bin\Release\**\publish\Newtonsoft.Json.dll" under "C:\vsts-agent-win-x64-2.144.0\_work\4\s" path.
Found: "C:\vsts-agent-win-x64-2.144.0\_work\4\s\xxx\bin\Release\netcoreapp2.2\publish\Newtonsoft.Json.dll"

Is there something I might be missing?

Shwetap05 commented 5 years ago

@jublair I am working on a fix in the library that should try to resolve the assembly conflicts if found any and hoping that should fix this Azure DevOps task issue too, i will keep you updated on the progress made.

ghost commented 5 years ago

Any updates?

Shwetap05 commented 5 years ago

I will have a PR out sometime over weekend. Though do not have an ETA on integration to task yet. But as soon as changes are in the library we will start work on updating the Task to consume the changes.

prafullbhosale commented 5 years ago

Hitting this same issue as well.

Shwetap05 commented 5 years ago

PR is out for the fix https://github.com/microsoft/OpenAPI.NET.CSharpAnnotations/pull/208

ShubhamRane commented 4 years ago

I can see that the above PR is merged. Is this issue resolved?. I am still facing this issue