RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.67k stars 1.23k forks source link

NSwag.MSBuild packages Newtonsoft.Json 11 instead of 9 #1796

Open paulomorgado opened 5 years ago

paulomorgado commented 5 years ago

I use NSwag.MSBuild in T4 templates and I have to load the specific assemblies into the template:

<#@ assembly name="System.Core"
#><#@ assembly name="System.Runtime"
#><#@ assembly name="System.Threading.Tasks"
#><#@ assembly name="$(NSwagDir)\Newtonsoft.Json.dll"
#><#@ assembly name="$(NSwagDir)\NJsonSchema.CodeGeneration.dll"
#><#@ assembly name="$(NSwagDir)\NJsonSchema.dll"
#><#@ assembly name="$(NSwagDir)\NJsonSchema.CodeGeneration.dll"
#><#@ assembly name="$(NSwagDir)\NJsonSchema.CodeGeneration.CSharp.dll"
#><#@ assembly name="$(NSwagDir)\NSwag.Core.dll"
#><#@ assembly name="$(NSwagDir)\NSwag.CodeGeneration.dll"
#><#@ assembly name="$(NSwagDir)\NSwag.CodeGeneration.CSharp.dll"
#><#@ import namespace="System.Linq"
#><#@ import namespace="System.IO"
#><#@ import namespace="System.Text.RegularExpressions"
#><#@ import namespace="Microsoft.CSharp"
#><#@ import namespace="NSwag"
#><#@ import namespace="NSwag.CodeGeneration"
#><#@ import namespace="NSwag.CodeGeneration.CSharp"
#><#@ output extension=".generated.cs"

The version of Newtonsoft.Json on the package is 11.0.0.0 while all the NJsonSchema and NSwag tooling has a dependency on 9.0.0.0.

RicoSuter commented 5 years ago

Where is this Newtonsoft.Json v11 package coming from?

paulomorgado commented 5 years ago

It's not the package. The Newtonsoft.Json.dll in nswag.msbuild\12.0.4\tools\Win is:

Version Kind Version
Assembly Version 11.0.0.0
Assembly Informational Version 11.2
Assembly File Version 11.0.2.21924

The package also contains NJsonSchema.dll 9.12.7.0 which requires Newtosoft.Json.dll 9.0.0.0.

As far as I know, there's no way to configure assembly bindings for T4 template processing.

RicoSuter commented 5 years ago

Ah man...

paulomorgado commented 5 years ago

Aren't assembly bindings fun? 😄

RicoSuter commented 5 years ago

What can we do about this? I dont want to downgrade the nswag newtonsoft version and dont want to break njs users :-)

paulomorgado commented 5 years ago

Maybe a specific package for T4 could be created with all correct versions and only the libraries need for that.

It would be a smaller package, even!

I have the same problems with the tooling I have built on top of NSwag.MSBuild for T4 templating. I need to keep all dependency versions aligned with the versions of NSwag.MSBuild's dependencies because there is no assembly binding redirection.