Question

After MSbuild has built my solution (with an asp.net website), and the webdeployment project has built and put the website in the directory _PublishedWebsites:

c:\mybuilds\buildName\Daily_20090519.3\Release_PublishedWebsites\MyWebsite.

How do I copy this to the fixed directory where IIS points to for the test website?

I have found loads of code snippets, but I cannot seem to find one that will take into account the fact that this directory name changes.

Was it helpful?

Solution

This is pretty easy. You can edit the project and insert something similar to the following.

<PropertyGroup>
  <OutputDest>$(MSBuildProjectDirectory)\..\OutputCopy\</OutputDest>
</PropertyGroup>
<Target Name="AfterBuild">
  <!-- Create an item with all the output files -->
  <ItemGroup>
    <_OutputFiles Include="$(OutputPath)**\*" Exclude="$(OutputPath)obj\**\*" />
  </ItemGroup>
  <!-- You probably don't want to include the files in the obj folder so exclude them. -->

  <Message Text="OutputDest : $(OutputDest)" />
  <Copy SourceFiles="@(_OutputFiles)"
        DestinationFiles="@(_OutputFiles->'$(OutputDest)%(RecursiveDir)%(Filename)%(Extension)')"/>
</Target>

Is this what you are looking for?

My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build

OTHER TIPS

I'm using different technique.

<PropertyGroup>
    <BinariesRoot>c:\BinariesForIis\</BinariesRoot>
</PropertyGroup>

The c:\BinariesForIis\ will be used for direct output compiled binaries (before copy to ...\Daily_20090519.3\Release_ ...).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top