Noel
Noel

Reputation: 5379

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

Upvotes: 1

Views: 2624

Answers (2)

P.Brian.Mackey
P.Brian.Mackey

Reputation: 44285

Put quotes around the file path.

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

Upvotes: 0

Noel
Noel

Reputation: 5379

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>

Upvotes: 3

Related Questions