【问题标题】:MSBuild - Just copy the files in TeamCityMSBuild - 只需复制 TeamCity 中的文件
【发布时间】:2013-10-04 04:48:58
【问题描述】:

我在 Team Foundation Server 项目中有文件夹和文件,在更改和签入时,需要将其部署到构建服务器上的文件夹中。没有解决方案或项目文件。

我对 MSBuild 不太熟悉,所以我为 TeamCity 中的 VS2012 项目制作了一个工作 build.xml,对其进行了编辑,以便它可以复制文件,但在 TeamCity 获取最新源后没有任何反应。

我在 build.xml 中做错了什么?

<?xml version="1.0" encoding="utf-8" ?>
 <Project DefaultTargets="Copy" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Target Name="Copy">
      <Copy SourceFiles="@(PackagedFiles)" 
            DestinationFiles="@(PackagedFiles->'\\SomeFolder\CredentialOnline\%(RecursiveDir)%(Filename)%(Extension)')"/>
 </Target> 
</Project>  

【问题讨论】:

  • @(PackagedFiles) 的内容是什么?你可以使用 Message 任务来显示它,比如&lt;Message Text="Files: @(PackagedFiles)"/&gt;

标签: msbuild teamcity


【解决方案1】:
<?xml version="1.0" encoding="utf-8" ?>
<Project DefaultTargets="CopyToDeployFolder" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="CopyToDeployFolder">
    <Exec Command="echo D| xcopy.exe  $(teamcity_build_checkoutDir) c:\Someplace /s /Y"  />

  </Target>
 </Project>  

【讨论】:

    【解决方案2】:

    下面将让您“微调”您想要的文件。 如果您不想排除任何内容,只需删除“Exclude=" 子句即可。

    仅供参考:WorkingDir 是一个自定义变量,即我的“根目录”。

    <ItemGroup>
        <MyExcludeFiles Include="$(WorkingDir)\**\SuperSecretStuff.txt" />
        <MyExcludeFiles Include="$(WorkingDir)\**\SuperSecretStuff.doc" />
    </ItemGroup>
    
    <ItemGroup>
        <MyIncludeFiles Include="$(WorkingDir)\**\*.*" Exclude="@(MyExcludeFiles)"/>
    </ItemGroup>        
    
    
    
    <Copy
    SourceFiles="@(MyIncludeFiles)"
    DestinationFiles="@(MyIncludeFiles->'$(OutputDir)\%(RecursiveDir)%(Filename)%(Extension)')"
    /> 
    

    您的“PackagedFiles”中可能没有任何内容。 这是一种列出它们的方法。

    <Message Text="List of files using special characters (carriage return)"/>
    <Message Text="@(PackagedFiles->'&quot;%(fullpath)&quot;' , '%0D%0A')"/>
    <Message Text="   "/>
    <Message Text="   "/>
    

    【讨论】:

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