7

We're running our own NuGet server to package our own projects. In this case, we're reusing some test builders. The unit tests pass when run locally, but through TFS 2015 some fail with the below error.

I've completed a Find in Files in these projects / packages to locate the 2.6.4 dependency without success.

What is AutoUnify, where is AutoUnify configured? Is disabling AutoUnify the correct approach to this problem?

 Unified Dependency "nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77".
         Using this version instead of original version "2.6.3.13283" in "D:\Agents\Agent1\c81e9061\eServices\.NugetLocalCache\EnterpriseApplications.Framework.Testing.1.0.0.0\lib\net45\EnterpriseApplications.Framework.Testing.dll" because AutoUnify is 'true'.
         Using this version instead of original version "2.6.3.13283" in "D:\Agents\Agent1\c81e9061\eServices\.NugetLocalCache\EnterpriseApplications.Framework.Testing.Mvc.1.0.0.0\lib\net451\EnterpriseApplications.Framework.Testing.Mvc.dll" because AutoUnify is 'true'.
         Could not resolve this reference. Could not locate the assembly "nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

Update: A good explanation of AutoUnify is via MSDN, but this does not explain how to disable

Update: These particular tests were failing only via TFS Build due to the version of the NUnit Test adapter being use by the build definition. Leaving this question open as it'd be interesting to hear where AutoUnify is configured.

Community
  • 1
  • 1
ManxJason
  • 928
  • 12
  • 33
  • Are you trying to enable restore NuGet package with TFS build? Please check http://stackoverflow.com/questions/32101429/tfs-2013-build-controller-not-respecting-nuget-package-restore – Cece Dong - MSFT Oct 22 '15 at 10:03
  • We have a working build step within our definitions that restores NuGet packages correctly. This particular issue was due to the version of NUnit Test Adapter being used by TFS Build. I've left the question open as I'm primarily asking for more information around AutoUnify and how to enable/disable. – ManxJason Oct 22 '15 at 10:18

5 Answers5

3

Not sure there's a way to directly "disable" autounify... However in VS2017 you can make the build fail when there're dependency conflicts. When the build fails it'll tell you the exact dlls that are conflicting and which project they're in.

Either modify your .csproj with this custom property

<MSBuildWarningsAsErrors>MSB3277</MSBuildWarningsAsErrors>

Or create a Directory.Build.props file at the solution level to impact all the projects in that solution. Directory.Build.props should have something similar to this xml:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
   <MSBuildWarningsAsErrors>MSB3277</MSBuildWarningsAsErrors>
  </PropertyGroup>
</Project>
tariq
  • 31
  • 3
1

It appears that the only way to disable the automatic binding redirects is to manually edit the project file of the unit test project (either .csproj or .vbproj). The link in Rob's answer walks you through how to do it, but essentially it is just changing this line:

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

to this:

<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
JamesQMurphy
  • 4,214
  • 1
  • 36
  • 41
1

I had a unit test which was failing at runtime and also saw warnings about conflicts. It said to check the build log on VERBOSE and I saw similar messages to yours.

I'd found that my Unit Tests app.config had assembly info in there that was pointing to the offending assemblies.

I created the issue by installing the latest RestSharp and JSON.net packages and then I downgraded them to much lower versions. The assembly info in the app.config pointed to these versions. This was able to be resolved by wiping those out of the app.config.

D-Sect
  • 537
  • 3
  • 10
  • 22
0

enabling / disabling the automatic binding redirects seems to enable/disable what is being reported as AutoUnify

for info on enabling / disabling the automatic binding redirects click here

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Rob
  • 3,488
  • 3
  • 32
  • 27
0

I had exactly the same problem:

In the App.config there were several <dependentAssembly> specified higher version of assembly than reference package one.

E.g. the Microsoft.Extensions.DependencyInjection.Abstractions, 2.2.0 NuGet package was needed and correctly referenced and installed/restored.

But the app.conf file required/unified the higher version:

<dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
Motlicek Petr
  • 767
  • 9
  • 10