Search code examples
visual-studio-2010msbuildbuild-processxcopy

Visual Studio BeforeBuild using xcopy command


I am using the following beforebuild target and this works fine:

<Target Name="BeforeBuild" Condition=" $(Configuration) == 'Debug' ">
    <Exec Command="xcopy ..\mycomponent\mylateboundassembly\bin\debug\*.* bin /q /r /y">
  </Target>

however when the folder mycomponent has a space in it (my component) which i cannot remove(legacy code), I cannot get xcopy to work

Anyone know a way use xcopy in beforebuild where paths have a space? Thanks


Solution

  • I got this to work by performing the following: Add an item to the property group (test)

     <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
            .....
        <Test>"..\x space\ClassLibrary2"</Test>
      </PropertyGroup>
    

    Then in Exec command use the property group item

    <Target Name="BeforeBuild" Condition=" $(Configuration) == 'Debug' ">
        <Exec Command="xcopy $(Test)\bin\Debug\*.* bin /q /r /y">
        </Exec>
      </Target>