chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
After upgrading to TypeMock 7.0 our build script fails to autodeploy/register TypeMock about 1/4 of the times. Rerunning the build fixes the issue, but it will fail again in a later build.

We autodeploy using the following msbuild script:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   
   <PropertyGroup>
      <TypeMockLocation>C:BuildAgentworkbee78bdf3a3ba14WorkingDirSWrdPartyTypeMockin</TypeMockLocation>
   </PropertyGroup>
   <Import Project ="$(TypeMockLocation)TypeMock.MSBuild.Tasks"/>

   <Target Name="RegisterTypeMock">
      <TypeMockRegister Company ="OurCompany" License="OurLicenseKey" AutoDeploy="True"/>
   </Target>

   <Target Name="StartTypeMock">
      <TypeMockStart/>
   </Target>

   <Target Name="UnRegisterTypeMock">
      <TypeMockStop UnDeploy="True"/>
   </Target>

</Project>

The error message when autodeploying is:
MockRegister.msbuild(8,10): error MSB4018: The "TypeMockRegister" task failed unexpectedly.
TypeMockRegister.msbuild(8,10): error MSB4018: System.OverflowException: Arithmetic operation resulted in an overflow.
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.Deploy.GACUtil.GetGACAssemblyPath(String assemblyName)
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.Deploy.AutoDeployTypeMock.RemoveGAC(Publish publisher, String assembly)
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.Deploy.AutoDeployTypeMock.DoGacInstall(Publish publisher, String interceptorsFilePath)
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.Deploy.AutoDeployTypeMock.Deploy(String rootDirectory)
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.CLI.Common.TypeMockRegisterInfo.Execute()
TypeMockRegister.msbuild(8,10): error MSB4018:    at TypeMock.MSBuild.TypemockTaskBase.Execute()
TypeMockRegister.msbuild(8,10): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
TypeMockRegister.msbuild(8,10): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
TypeMockRegister.msbuild" (RegisterTypeMock target(s)) -- FAILED.
asked by halstein (8.7k points)

18 Answers

0 votes
One additional information that was actually missing from the previous error. I'm not sure if this changes anything but our Windows is not located in the default path. The error is like this

error CS0006: Metadata file 'C:ETPWINssemblyGAC_MSILConfiguration.0.4.0__3dae460033b8d8e2Configuration.dll' could not be found
answered by JK (3.1k points)
0 votes
Hi,
When do you get this error? Is it a build error?
In any case I sent you mail with a link to download for a version that will give us better information about the error.
answered by ohad (35.4k points)
0 votes
No, this is not a build error. This is step where the project is already build and the unit tests are about to starts. Build server is initializing the TypeMock auto deployment when this error happens.
answered by JK (3.1k points)
0 votes
Update: 7.0.5 is also broken. Last auto deployable version is still 7.0.1.
answered by halstein (8.7k points)
0 votes
Hi Halstein,

Are you using several versions of typemock?

Please check the GAC is empty besides only one dll: typemock.interceptors.dll version 7.0.5

Other dlls that used to be in there shouldn't: Typemock.dll and Configuration.dll
answered by yoel (1.9k points)
0 votes
It seems that the v7 has destroyed the auto deployment totally. Can somebody link to the release note or documentation page where all this GAC and registration issues are documented so that the user can setup their CI systems according to new changed?

We have been using our MsBuild scripts with typemock very long time without any problems. Now v7 has changed everything and not for good :(
answered by JK (3.1k points)
0 votes
Hi Yoel!

Yes, we use many different versions of TypeMock. This is the reason we auto deploy TypeMock instead of just installing it on the build agents. We have about 50 build configurations in our TeamCity server and probably 10-20 different versions of TypeMock used in them. The auto deploy feature allows us to use the latest TypeMock on our development branches, while we at the same time maintain multiple old stable versions of our applications that use older version of TypeMock.

Now to the question about the GAC: Yes, there are several versions of TypeMock assemblies in there. All of them from the 7.0.x line. Could this mean that it is the undeploy functionality that is broken in 7.0.x? Or maybe it is just 7.0.1 that decided to leave its TypeMock.dll behind and mess it up for the newer versions.

The assemblies in the GAC are as follows:
TypeMock 7.0.1
TypeMock.Interceptors 7.0.5
TypeMock.Interceptors 7.0.4
TypeMock.Interceptors 7.0.3
TypeMock.Interceptors 7.0.2
TypeMock.Interceptors 7.0.1

We did use TypeMock 7.0.0 when it first came out, but this version seems to have cleaned itself up since it didn't leave anything in the GAC.

I will try to remove them all and see if I am then able to autodeploy 7.0.5.
answered by halstein (8.7k points)
0 votes
My issue was caused by TypeMock not undeploying properly and left old versions of itself in the GAC. To fix it I made a little .bat file I run at the beginning of my build script:
gacutil /u TypeMock
gacutil /u TypeMock.Interceptors
gacutil /u Configuration


With this I am now able to use the latest version of TypeMock and auto deploy it.
answered by halstein (8.7k points)
...