Web Deployment Projects: copy build output to a network share

Last post 11-11-2005 5:12 PM by HarryPfleger. 2 replies.

Sort Posts:

  • Web Deployment Projects: copy build output to a network share

    11-10-2005, 5:31 AM
    • Member
      25 point Member
    • HarryPfleger
    • Member since 06-03-2005, 2:05 AM
    • Posts 5

    I'd like to copy the build output of the Web Deployment Project, after a successfull build, to a network share.
    How could I achive this?
    Thankx!

  • Re: Web Deployment Projects: copy build output to a network share

    11-10-2005, 3:04 PM
    • Participant
      1,171 point Participant
    • BradleyB
    • Member since 11-06-2002, 3:53 PM
    • Posts 227

    The easy way to do this is to override the after build event with your own custom action:

      <Target Name="AfterBuild">
        <Exec Command="xcopy /s /e /y /i $(WDTargetDir)*.* \\dropserver\public\drops\$(Configuration)"/>
      </Target>

    Notice that I've used $(Configuration) in the network share path.  This is to allow droping both staging and release builds.  If you're not going to use configurations this way you can omit the $(Configuration) from the path.

    Alternatively you could use the built in <copy > task http://msdn2.microsoft.com/en-us/library/3e54c37h(en-US,VS.80).aspx

      <Target Name="AfterBuild">
      
        <CreateItem Include="$(WDTargetDir)\**\*.*">
          <Output ItemName="PrecompiledWeb" TaskParameter="Include"/>
        </CreateItem>

        <Copy  SourceFiles="@(PrecompiledWeb)" DestinationFolder="\\dropserver\public\drops\$(Configuration)\%(PrecompiledWeb.SubFolder)%(PrecompileWeb.RecursiveDir)"/>
       
      </Target>

    The copy task requires an item list so you have to create the Item list recursing the folders.  You may also want to ensure that the target folder on the network share is empty to do that call the RemoveDir task before the copy.

        <RemoveDir Directories="\\dropserver\public\drops\$(Configuration)"/>

    If you're going to be referencing the network share in multiple places in the project you should probably create a property with that value.

      <PropertyGroup>
        <NetworkShare>\\dropserver\public\drops\$(Configuration)</NetworkShare>
      </PropertyGroup>

    Alternatively you could define the property in the task itself.

      <Target Name="AfterBuild">
        <CreateProperty Value="\\dropserver\public\drops\$(Configuration)\">
          <Output PropertyName="NetworkShare" TaskParameter="Value"/>
        </CreateProperty>

        <RemoveDir Directories="$(NetworkShare)"/>
        <Exec Command="xcopy /s /e /y /i $(WDTargetDir)*.* $(NetworkShare)"/>

      </Target>

    You can find more on MSBuild at http://msdn2.microsoft.com/en-us/library/ms171452

  • Re: Web Deployment Projects: copy build output to a network share

    11-11-2005, 5:12 PM
    • Member
      25 point Member
    • HarryPfleger
    • Member since 06-03-2005, 2:05 AM
    • Posts 5
    Thankx BradleyB, that helps a lot!
    Do you think it would be possible to have a dialog box poping up before doing the copy?
    Something like "Would you like to copy?" YES/NO and according to the choice the copy would happen or not?
Page 1 of 1 (3 items)