在TeamCity中使用MSBuild复制文件

3
我有以下的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”作为目标放置。

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


2
将 /v:d 或 /v:diag 添加到 MSBuild 参数中,输出将告诉您。 - Ruben Bartelink
1
我的源文件(MySourceFiles)和源文件(SourceFiles)可能是问题所在。 - Ruben Bartelink
@Ruben - 我的愚蠢似乎没有止境!我不敢说你发现得好。 - DavidS
@DavidS:底线是,为了解决所有这些问题,必须在所有 MSBuild 问题下 jamming in 一个 /v:d 或 /v:diag,在 TeamCity(或任何地方)都是一样的。 - Ruben Bartelink
@Ruben - 谢谢。我正在尝试查看脚本是否正常工作,并已添加参数。然而,另一位开发人员进行了一些更改,这意味着我甚至无法构建解决方案,因此我甚至没有复制的机会。我会相应地更新。 - DavidS
@Ruben - 你是对的。MySourceFiles与Sourcefiles之间的区别是问题所在。也许你想把答案放在这里,这样你就可以得到荣誉:)。我本来想抹掉它,但/v:d或/v:diag的建议很好。 - DavidS
1个回答

6
对于在TeamCity下无法正常工作的MSBuild问题,几乎总是需要添加/v:d(执行的每个步骤以及跳过步骤的信息)或/v:diag(详细信息加上ItemGroup的转储等诊断目的),将它们添加到MSBuild参数中,然后TeamCity管理的构建输出就会有答案。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接