-
Notifications
You must be signed in to change notification settings - Fork 325
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
Remove binding redirect of Newtonsoft.Json from testhost config file #663
Conversation
1) microsoft#391 2) microsoft#613 Fix: Remove binding redirect of Newtonsoft.json from testhost config file
@Faizan2304, |
scripts/build.ps1
Outdated
# Binding redirection for Newtonsoft.Json.dll has been removed from testhost config file to resolve bug: https://github.com/Microsoft/vstest/issues/391 | ||
# Microsoft.TestPlatform.CommunicationUtilities depends on Newtonsoft.Json of version 8.0.3 and Microsoft.TestPlatform.CrossPlatEngine depends on Microsoft.Extensions.Dependencymodel which | ||
# depends on Newtonsoft.Json of version 9.0.1. So at the end testhost has Newtonsoft.Json.dll of version 9.0.1 in their publish package. | ||
# Since testhost uses CommunicationUtilities (and dont use that part of code of CrossPlatEngine which uses Newtonsoft.Json of version 9.0.1) so it needs Newtonsoft.Json.dll of version 8.0.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to include why we made this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also state that we have a very thin line on cross plat engine's dependency on newtonsoft.json 9.0.1(It actually should be just calling into 8.0.3 compatible APIs since that's what it finds at runtime.)
@@ -10,6 +10,8 @@ | |||
<TargetFrameworks>netcoreapp1.0;net46</TargetFrameworks> | |||
<AssemblyName>Microsoft.TestPlatform.Client.UnitTests</AssemblyName> | |||
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback> | |||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | |||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to figure out what this actually means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Faizan2304 why is this required for TP.Client.UnitTests? Can we add a comment please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TP.Client.UnitTests has dependency on both version 8 and 9 of Newtonsoft.Json, hence higher version(9) get copied in output folder . We have removed the binding redirect of Newtonsoft.Json from testhost config file So the appdomain which runs the test doesn't have any binding redirect of Newtonsoft.json, as a result when the test run it loads the version 9 of Newtonsoft.Json. when the code which uses Newtonsoft.Json (8) get executed it fails with method not found exception.
@dotnet-bot test this please |
scripts/build.ps1
Outdated
# In the TestPlatform repo: Microsoft.TestPlatform.CommunicationUtilities depends on Newtonsoft.Json(8.0.3) and Microsoft.TestPlatform.CrossPlatEngine depends on Microsoft.Extensions.Dependencymodel which | ||
# depends on Newtonsoft.Json(9.0.1). So testhost ends up having Newtonsoft.Json.dll of version 9.0.1 in their publish package. | ||
# Since testhost uses CommunicationUtilities (and does not use that part of CrossPlatEngine which uses Newtonsoft.Json of version 9.0.1) so it needs Newtonsoft.Json.dll of version 8.0.3 along with it. | ||
# Hence, copying Newtonsoft.Json.dll of version 8.0.3 to test $testhostFullPackageDir. This is however very much dependent on the CrossPlatEngine code running in testhost to not call into APIs specific to 9.0.1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're copying the JSON.net since CommunicationUtilities requires it. Suggest adding this root cause to the actual bug and refer it here for history.
After refactoring of test host providers, CrossPlatEngine no longer takes a dependency on JSON.net.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in next commit
scripts/build.ps1
Outdated
$newtonsoft = Join-Path $env:TP_PACKAGES_DIR "newtonsoft.json\8.0.3\lib\net45\Newtonsoft.Json.dll" | ||
Copy-Item $newtonsoft $testhostFullPackageDir -Force | ||
|
||
# Copy over the Full CLR built testhost package assemblies to the Core CLR and Full CRL package folder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/CRL/CLR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in next commit
@@ -14,6 +14,7 @@ | |||
</PropertyGroup> | |||
<PropertyGroup Condition="'$(TargetFramework)' != 'netcoreapp1.0'"> | |||
<RuntimeIdentifier>win7-x64</RuntimeIdentifier> | |||
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment why is this required. CrossPlatEngine no longer has a dependency on JSON.net.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after PR #659, we may not need this.
@@ -12,6 +12,7 @@ | |||
</PropertyGroup> | |||
<PropertyGroup Condition="'$(TargetFramework)' != 'netcoreapp1.0'"> | |||
<RuntimeIdentifier>win7-x64</RuntimeIdentifier> | |||
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be this is not required since CrossPlatEngine is not dependent on JSON.net.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will remove after testing once Mayank fix will go in
@@ -11,6 +11,8 @@ | |||
<AssemblyName>Microsoft.TestPlatform.CommunicationUtilities.UnitTests</AssemblyName> | |||
<EnableCodeAnalysis>true</EnableCodeAnalysis> | |||
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback> | |||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Require comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for all changes below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with few suggestions.
@dotnet-bot test this please |
1 similar comment
@dotnet-bot test this please |
…e to do this because the folder which contains datacollector has Newtonsoft.Json(9.0) and datacollect depends on 8.0.
Issues:
Fix: Remove binding redirect of Newtonsoft.json from testhost config file