Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio persists on using UnitTestFramework 10.0.0.0

I've got a solution with several projects in it. One of the projects includes additional Assert methods for unit testing. It references Microsoft.VisualStudio.QualityTools.UnitTestFramework 10.1.0.0. It also includes other test projects, which reference both Microsoft's UnitTestFramework and my project with additional assert methods.

Whenever I restart visual studio and compile, I get the following warning:

Found conflicts between different versions of the same dependent assembly.

I have tried changing all the references to the UnitTestFramework to 10.1.0.0, but upon restarting Visual Studio seems to set them to 10.0.0.0 again. I have even tried changing the project file outside of Visual Studio, but upon opening the project in Visual Studio the references show the old version in the solution explorer again. When closing Visual Studio without doing any file modifications, it asks whether or not to save changes to the project files.

How do I prevent Visual Studio from changing the version of my referenced UnitTestFramework in my projects?

like image 293
Steven Jeuris Avatar asked Mar 24 '12 17:03

Steven Jeuris


1 Answers

Had same problem. One of our developers was reorganizing assemblies and his VS for some unknown reason changed this:

<Choose>
  <When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
    <ItemGroup>
      <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
    </ItemGroup>
  </When>
  <Otherwise>
    <ItemGroup>
      <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
    </ItemGroup>
  </Otherwise>
</Choose>

into this:

<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Choose>
  <When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
    <ItemGroup>
      <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
    </ItemGroup>
  </When>
  <Otherwise />
</Choose>

The first line of which kept getting changed on everyone else's system (same symptoms as you).

Since we have no plans to support 3.5 anyway, I fixed it by removing the "Choose" section and simplifying into:

<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />

(removing the specific version altogether from the reference)

like image 75
Mike Asdf Avatar answered Nov 13 '22 23:11

Mike Asdf