由于 TeamCity 构建测试程序集错误,无法运行 MSpec 测试

发布于 2024-10-31 02:31:26 字数 2146 浏览 4 评论 0原文

我正在尝试在构建解决方案后运行 MSpec 测试。因此,我的 MSBuild 脚本设置如下:

<?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 MSpec" Importance="high" />  
      </Target>
    </Project>

然后我在 TeamCity 中调用“TeamCity”作为我的目标。当命令

“mspec.exe ..\Hosts\MyApplication.Hosts.Web.Specs\bin\MyApplication.Hosts.Web.Specs.dll --团队城市”

执行后,出现以下错误:

C:\TeamCity\buildAgent\work\117e3aa3bb76aad0\Build>mspec ..\Hosts\Application.Hos ts.Web.Specs\bin\Application.Hosts.Web.Specs.dll 无法加载文件或程序集'file:///C:\TeamCity\buildAgent\work\117e3aa3bb7 6aad0\Hosts\Application.Hosts.Web.Specs\bin\Application.Hosts.Web.Specs.dll' 或 e 其依赖项。试图加载一个错误的程序 格式。

经过一番调查后,我发现本地计算机和构建服务器上的“MyApplication.Hosts.Web.Specs.dll”虽然都是 15kb,但具有不同的 md5 校验和。这也许可以解释为什么执行 MSpec 测试会导致错误。事实上,如果我将 dll 从本地计算机复制到构建服务器,测试就会运行。

所以我的问题是其他人是否也遇到过同样的问题,即装配体的构建“糟糕”?

-编辑- 在本地,我将解决方案构建为 64 位应用程序,但在 TeamCity 中,我将其构建为 32 位 (x86)。这可能是问题所在吗?

PS:我尝试在 TeamCity 中将其构建为 64 位应用程序,但出现了其他错误,我暂时宁愿忽略这些错误。然而,为了完整起见,这里是:

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.

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 MSpec" 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诺曦 2024-11-07 02:31:26

David,

  • 您是哪个版本的 MSpec
    跑步?如果你还在 0.3.0.0 我
    鼓励您切换到
    最近的 0.4.9.0 版本
    。这个构建
    还包含 mspec.exe (AnyCPU)
    作为 mspec-x86.exe (x86)。你应该
    使用与您的版本匹配的可执行文件
    环境/架构。

  • 你能追踪一下组装过程吗
    与 Fusion Log Viewer 绑定 -
    它是 Windows SDK 的一部分。这
    错误消息“已尝试
    加载一个不正确的程序
    格式。”表示 MSpec 能够
    查找规范 DLL,但目标
    架构之间不匹配
    MSpec 可执行文件和规范
    组装。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文