开发者

Daily builds with MsBuild

What i want to do is to copy all files and subfolders from the OutputPath to the daily folder. For example i have project called Clock, i have msbuild script for it:

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <ProjectPath>C:\Clock</ProjectSolutionName>
    <ProjectSolutionName>Clock</ProjectSolutionName>
  </PropertyGroup>

  <Target Name="ReleaseBuild">
    &开发者_运维问答lt;Message Text="Building $(ProjectSolutionName) Release Build" />
    <MSBuild Projects="$(ProjectPath)\$(ProjectSolutionName).sln" Targets="Clean" Properties="Configuration=Release" />
    <MSBuild Projects="$(ProjectPath)\$(ProjectSolutionName).sln" Targets="Build" Properties="Configuration=Release" />
    <Message Text="$(ProjectSolutionName) Release Build Complete!" />
  </Target>
</Project>

Now when i run the script it compiles the solution and the files will be stored to a Release folder. How could i copy all the files and subfolders from the Release folder to folder named as the date, as for today for example: C:\Clock_Builds\20110803


This should do most of what you ask (its msbuild 4):

<Project DefaultTargets="DateCopy" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Target Name="DateCopy">
   <ItemGroup>
      <Release Include="d:\Build\**\**"/>
   </ItemGroup>

   <PropertyGroup>
      <StringDate>$([System.DateTime]::Now.ToString('yyyyMMdd'))</StringDate>
   </PropertyGroup>

   <MakeDir Directories="D:\Release\$(StringDate)"/>

   <Message Text="$(StringDate)" Importance="High"/>
   <Copy SourceFiles="@(Release)"
         DestinationFolder="D:\Release\$(StringDate)\%(RecursiveDir)"/>
</Target>
</Project>

Hope that helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜