Visual Studio BeforeBuild using xcopy command
-
12-10-2019 - |
Question
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>
OTHER TIPS
Put quotes around the file path.
<Target Name="BeforeBuild" Condition=" $(Configuration) == 'Debug' ">
<Exec Command="xcopy \"..\mycomponent\mylateboundassembly\bin\debug\*.*\" bin /q /r /y">
</Target>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow