Unable to run MSpec test due to the fact that TeamCity is building test assembly wrong
I am trying to run a MSpec test following the build of my solution. So, I've got my MSBuild script set up as follows:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Build">
<MSBuild Projects="../MyApplication.Web.sln" />
<Message Text="Building solution" Importance="high" />
</Target>
<Target Name="TeamCity" DependsOnTargets="Build">
<Message Text="Before executing MSpec command" Importance="high" />
<Exec Command="mspec.exe ..\Hosts\MyApplication.Hosts.Web.Specs\bin\MyApplication.Hosts.Web.Specs.dll --teamcity" />
<Message Text="Running MSp开发者_开发问答ec" Importance="high" />
</Target>
</Project>
I then call "TeamCity" as my target in TeamCity. When the command
"mspec.exe ..\Hosts\MyApplication.Hosts.Web.Specs\bin\MyApplication.Hosts.Web.Specs.dll --teamcity"
is executed, I get the following error:
C:\TeamCity\buildAgent\work\117e3aa3bb76aad0\Build>mspec ..\Hosts\Application.Hos ts.Web.Specs\bin\Application.Hosts.Web.Specs.dll Could not load file or assembly 'file:///C:\TeamCity\buildAgent\work\117e3aa3bb7 6aad0\Hosts\Application.Hosts.Web.Specs\bin\Application.Hosts.Web.Specs.dll' or on e of its dependencies. An attempt was made to load a program with an incorrect f ormat.
After doing some investigation, I found out that the "MyApplication.Hosts.Web.Specs.dll" on my local machine and the build server, although both 15kb, had different md5 checksums. That might explain why the execution of the MSpec test would cause errors. In fact, if I copy the dll from my local machine to the build server, the test will run.
So my question is whether someone else has come across this same issue of the builiding of assemblies being build "badly"?
-EDIT- Locally I'm building the solution as a 64 bit application but in TeamCity, I'm building it as 32 bits (x86). Could that be the problem?
PS:I tried building it as a 64 bit application in TeamCity but I get other errors which I would rather ignore for the moment. However, for completeness sake here it is:
Client\ProdMaster.SLCharts\ProdMaster.SLCharts.csproj
[15:11:22]: [Client\ProdMaster.SLCharts\ProdMaster.SLCharts.csproj] GetFrameworkPaths
[15:11:22]: [GetFrameworkPaths] ValidateSilverlightFrameworkPaths
[15:11:22]: [ValidateSilverlightFrameworkPaths] C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.Common.targets(104, 9): The Silverlight 4 SDK is not installed.
David,
Which version of MSpec are you running? If you're still on 0.3.0.0 I encourage you to switch to the most recent 0.4.9.0 build. This build contains mspec.exe (AnyCPU) as well as mspec-x86.exe (x86). You should use the executable matching your build environment/architecture.
Can you please trace the assembly binding with Fustion Log Viewer - it's part of the Windows SDK. The error message "An attempt was made to load a program with an incorrect format." indicates that MSpec is able to find the spec DLL, but target architectures do not match between the MSpec executable and and spec assembly.
精彩评论