Sunday, May 22, 2011

Microsoft.BizTalk.TestTools.Mapper.TestableMapBase erroring in Team Build

Have you recently attempted to use the Microsoft.BizTalk.TestTools.Mapper.TestableMapBase (This class enables you to test BizTalk maps programmatically through MSTest or NUnit) on the build server as a CI process or otherwise through some sort of test harness, if so, you might have received the following error:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.BizTalk.TOM, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

This was happening in a new development environment during the execution of MSTest unit tests against BizTalk 2010 Developer Edition and a Team Foundation 2010 build during a CI build process.

After searching around and reading various blog posts, I couldn't find the solution other than to repair BizTalk. This sounded rather drastic to fix a simple error. So I then decided to do the normal thing a .NET developer would do and check the GAC for the file Microsoft.BizTalk.TOM. I failed to find it so I guess the BizTalk installation must have failed somewhere, as I didn't install BizTalk on that machine it's hard to know.

So I then decided to GAC the file. Looking for GACUTIL.exe, I soon realised and remembered that GACUTIL is not supplied with the .NET Framework. As this was a build server, I didn't have Visual Studio installed. Then I remembered I installed the Windows Server SDK v6.1 on this machine so that I could actually build code and run tests (due to various build targets that comes with the Windows Server SDK). When you install the Windows SDK it comes with a CMD.cmd file and GACUTIL.exe (among other things) that sets up the environment ready to use the various tools.

So to fix this missing assembly issue:

1. if you don't have the Windows SDK installed install it (latest version at the time of writing is
v6.1)
2. Once the SDK is installed, run this: C:\Windows\System32\cmd.exe /E:ON /V:ON /T:0E /K "D:\Program Files\Microsoft SDKs\Windows\v6.1\Bin\SetEnv.Cmd" This is assuming you have installed the SDK on a drive D.
3. Run the following command: GACUTIL C:\Program Files (x86)\Common Files\Microsoft BizTalk\Microsoft.BizTalk.TOM.dll -i

Queue a build, or attempt to run the app using the map test class and all should be well (unless you have other issues!)

2 comments:

Prasanna K Rao said...

Hi Simon,

Thanks a lot for this. After GAC'ing this `TOM` dll, I get a new exception now. The exception message is `transform failure`. There is no useful info in the inner exception. Would you happen to know the cause for this issue please?

Thanks,
Prasanna K Rao

Lee Simpson said...

Test the transform in Visual Studio IDE - you get better error details.