【问题标题】:Copying files using MSBuild in TeamCity在 TeamCity 中使用 MSBuild 复制文件
【发布时间】:2011-08-18 08:49:40
【问题描述】:

我有以下 xml 文件:

<?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="DeployPrototype" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <dotCover>..\..\..\plugins\dotCover\bin\dotCover.exe</dotCover>
      </PropertyGroup>
      <ItemGroup>
        <SourceFiles Include="..\Prototype\Site\Site\Bin\TestServer\Default.html;..\Prototype\Site\Site\Bin\TestServer\Site.xap"/>
        <DestinationFolder Include="C:\inetpub\wwwroot\ProjectName\Prototype"/>
      </ItemGroup>

      <Target Name="Build">
          <MSBuild Projects="../ProjectName.Web.sln" Properties="Configuration=testserver" />
          <Message Text="Building ProjectName solution" Importance="high" />
      </Target>

      <Target Name="TeamCity" DependsOnTargets="Build">
        <Message Text="Before executing MSpec command" Importance="low" />
        <Exec Command="..\packages\Machine.Specifications.0.4.10.0\tools\mspec-clr4.exe ..\Hosts\ProjectName.Hosts.Web.Specs\bin\ProjectName.Hosts.Web.Specs.dll --teamcity" />
        <Message Text="Ran MSpec" Importance="low" />
        <Exec Command="$(dotCover) c TestServerBuildAndRunTestsOnly_DotCover.xml" />
        <Message Text="##teamcity[importData type='dotNetCoverage' tool='dotcover' path='build\coverage.xml']" Importance="high" />
      </Target>

      <Target Name="DeployPrototype" DependsOnTargets="TeamCity">
        <Message Text="Before executing copy, source files are: @(MySourceFiles) and destination folder is: @(DestinationFolder)" Importance="low" />
            <Copy
              SourceFiles="@(MySourceFiles)"
              DestinationFolder="@(DestinationFolder)"
      />
        <Message Text="Atter executing copy" Importance="low" />
      </Target>
    </Project>

除了复制文件之外,此脚本中的所有内容都有效。我放在复制部分的消息不会出现在 TeamCity 的完整日志中。在后者的配置设置中,我将“DeployPrototype”作为我的目标。

为什么复制操作没有发生?

【问题讨论】:

  • 在 MSBuild 参数中添加 /v:d 或 /v:diag,输出会告诉你
  • MySourceFiles vs SourceFiles 可能是问题 tho7ugh
  • @Ruben - 我的愚蠢似乎无止境!我犹豫说好地方。
  • @DavidS:最重要的是,所有这些问题的关键在于所有 MSBuild 问题的 /v:d 或 /v:diag 中,无论是在 TeamCity 下(或任何地方)
  • @Ruben - 谢谢。我正在尝试查看脚本现在是否正在运行并且我已经添加了参数。但是,其他开发人员之一进行了一些更改,这意味着我什至无法构建解决方案,因此我什至没有达到复制的目的。我会相应地更新

标签: msbuild teamcity


【解决方案1】:

对于涉及 MSBuild 无法在 TeamCity 下运行的给定问题,答案几乎总是涉及添加 /v:d(执行的每个步骤以及有关跳过的步骤的信息)或 /v:diag(详细加上 ItemGroups 等的转储)诊断目的)到 MSBuild 参数和 TeamCity 管理的构建输出将有答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-11
    • 2014-09-14
    • 2011-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多