UnitTestFramework from MSBEE - not found ERROR, but referenced

Topics: For MSBee Users
Aug 16, 2006 at 10:03 PM
migrated from power toy forums
originally posted by stiversj
------------------------------------------------------

Any approaches reccommended for coverting VS2005 unittests (via Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe) thru MSBee for 1.1 compatitibility ?

What we are trying to do is :

1) Write VS unittests against the 2.0 code.

2) Convert 2.0 code to 1.1 with MSBEE

3) Convert the VS unittests to 1.1 with MSBEE

4) The unittests project has the unittestFramework reference set AND a ref to the the 2.0 project it is testing.

In CoreCompile, we get this error :

CSC : error CS0006: Metadata file '..\..\..\..\..\..\..\WINNT\assembly\GAC_MSIL\
Microsoft.VisualStudio.QualityTools.UnitTestFramework\8.0.0.0__b03f5f7f11d50a3a\
Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll' could not be found

It seems to say it cannot find the UnitTestFramework - but it is clearly referenced in the unittests project.

Is there perhaps something needed in the targets for the UnitTestFramework.exe like a manual import in the project file or targets file or as a reference item in :

:MSBee\MSBuildExtras.FX1_1.CSharp.targets ??
Aug 16, 2006 at 10:03 PM
originally posted by stiversj
------------------------------------------------------

HA!

Just for giggles i deleted that unittestframework ref and readded it (like some NUNIT issues) ... and it resolved OK in the CoreCompile.
Aug 16, 2006 at 10:04 PM
originally posted by Bertan Aygun - MSFT
------------------------------------------------------

Hi,

It should not be possible to compile unit test projects using MSTest with 1.1 compilers since UnitTestFramework.dll is a .Net 2.0 dll and .Net 1.1 compilers would not work with it.

Please make sure you are not building your project in Visual Studio 2005; MSBee doesn’t work from within Visual Studio so you’ll always get a .NET 2.0 build. When building on the command line, make sure you are setting TargetFX1_1 property to true when calling MSBuild. Otherwise, MSBuild doesn’t use the MSBee .targets file so the .NET 2.0 compilers are used instead.


Please let me know if project is still succesfully built with changes above since it would be an interesting issue to look at.
Aug 16, 2006 at 10:04 PM
originally posted by stiversj
------------------------------------------------------

True, MSTest artifacts likeTestProject with those TestMethods and TestClass attributes does not build with MSBEE to 1.1, as expected.

And yes, only by TargetFX1_1 property to true (per MSBEE doc sectioin 4.2) when calling MSBuild do I get the VS2005 project built from the command line. Checking with ILDASM Manifest shows I produce the expected 1.1 version from VS 2005 code. Nice.

Then, I changed the reference for the VS Unittest from the previous 2.0 Build to that MSBEE 1.1 build component. The tests still worked from VS2005, as well as a command line MSTEST i run from batch which produces an XSL CruiseControl format report for continuous test reporting. Again, nice.

So, my proof of concept seems successful so far in that I got my VS2005 project code and the VS Unittest project against the project code. Then, the project code is MSBEE'd to run in 1.1. And the command line MSTest uses the testcontainer of my VS2005 2.0 UnitTest Project with a ref to that 1.1 for the MS unittests.

Note, the UnitTest Project is initally pointing to the VS2005 2.0 code and then after i add methods to be tested, and then the new test methods to the test project, I then MSBEE from the command line to get the new 1.1 component from only the code project (not the unittest project) and then remove the ref for the unittest project to the VS2005 build to that MSBEE build component.

Hope this makes sense.

Thanks
Aug 16, 2006 at 10:04 PM
originally posted by Bertan Aygun - MSFT
------------------------------------------------------

It is much clear now. If you don't want to change references manually in UnitTest project you can use conditional ItemGroups to automatically change reference to project file depending on TargetFX1_1 property. Code to add to project file would look like:

<ItemGroup Condition=" '$(TargetFX1_1)' != 'true' ">
<Reference Include="2.0 project dll" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFX1_1)' == 'true' ">
<Reference Include="1.1 project dll" />
</ItemGroup>

You should be able to now call msbuild on UnitTest project file and if you set TargetFX1_1 property to true, it will build the test dll using output from 1.1 code.

Thanks,
Bertan
Aug 16, 2006 at 10:04 PM
originally posted by john_stivers
------------------------------------------------------

ahhhh,

yes, this is needed, also

nice

thanks
Aug 16, 2006 at 10:04 PM
originally posted by Craig Lichtenstein - MSFT
------------------------------------------------------

Another option is to use MSBuild's <Choose> element. You could do something like:

<Choose>

<When Condition=" '$(TargetFX1_1)' == 'true' ">

<ItemGroup>

<Reference Include="1.1 project dll" />

</ItemGroup>

</When>

<Otherwise>

<ItemGroup>

<Reference Include="2.0 project dll" />

</ItemGroup>

</Otherwise>

</Choose>

See MSDN for more information.