开发者

Problems with Copy Target in TFSBuild.proj

As part of my TFS (2008) build I want to manually copy the binaries and Views of an ASP.NET MVC project to a number of different locations. All existing binaries and views are copied successfully. Unfortunately, however, any newly added views are ignored 开发者_运维技巧during their first build. If I then start another build, they are included.

Here is a snippet of the additions I have made to TFSBuild.proj...

<ItemGroup>
  <BinaryFiles Include="$(BinariesRoot)\Debug\_PublishedWebsites\SiteName\bin\*.*" />
  <ViewFiles Include="$(BinariesRoot)\Debug\_PublishedWebsites\SiteName\Views\**\*.aspx" />
  <ViewFiles Include="$(BinariesRoot)\Debug\_PublishedWebsites\SiteName\Views\**\*.ascx" />
</ItemGroup>

<Target Name="AfterDropBuild">
  <Message Text="Starting deployment copy..." />
  <Copy SourceFiles="@(BinaryFiles)" DestinationFolder="T:\BuildWebSiteHosting\WebSite\bin\" ContinueOnError="false" />
  <Copy SourceFiles="@(ViewFiles)" DestinationFolder="T:\BuildWebSiteHosting\WebSite\Views\%(RecursiveDir)" ContinueOnError="false" />
  <Message Text="Deployment copy completed." />
</Target>

I suspect that the list of files to copy is being built too early. Should I be using "AfterDropBuild" or is their a better target name?


I managed to solve this one myself (it was very helpful just asking the question and organising my own thoughts!). My suspicions that the lists of files were being built too soon were correct. By placing the ItemGroup inside the Target element you can specify when it is evaluated.

Corrected snippet is:

<Target Name="AfterDropBuild">
  <ItemGroup>
    <BinaryFiles Include="$(BinariesRoot)\Debug\_PublishedWebsites\SiteName\bin\*.*" />
    <ViewFiles Include="$(BinariesRoot)\Debug\_PublishedWebsites\SiteName\Views\**\*.aspx" />
    <ViewFiles Include="$(BinariesRoot)\Debug\_PublishedWebsites\SiteName\Views\**\*.ascx" />
  </ItemGroup>

  <Message Text="Starting deployment copy..." />
  <Copy SourceFiles="@(BinaryFiles)" DestinationFolder="T:\BuildWebSiteHosting\WebSite\bin\" ContinueOnError="false" />
  <Copy SourceFiles="@(ViewFiles)" DestinationFolder="T:\BuildWebSiteHosting\WebSite\Views\%(RecursiveDir)" ContinueOnError="false" />
  <Message Text="Deployment copy completed." />
</Target>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜