【问题标题】:Visual Studio BeforeBuild using xcopy commandVisual Studio BeforeBuild 使用 xcopy 命令
【发布时间】:2010-12-20 20:40:26
【问题描述】:

我正在使用以下 beforebuild 目标,这工作正常:

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

但是,当文件夹 mycomponent 中有一个空间(我的组件)我无法删除(遗留代码)时,我无法让 xcopy 工作

有人知道在路径有空格的 beforebuild 中使用 xcopy 的方法吗? 谢谢

【问题讨论】:

    标签: visual-studio-2010 msbuild build-process xcopy


    【解决方案1】:

    我通过执行以下操作使其工作: 将项目添加到属性组(测试)

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

    然后在 Exec 命令中使用属性组项

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

    【讨论】:

      【解决方案2】:

      在文件路径周围加上引号。

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

      【讨论】:

      • 抱歉没有说完。所以我然后尝试了 Command="xcopy '..\mycomponent\mylateboundassembly\bin\debug*.*' bin /q /r /y"> 但现在出现错误 1 ​​The command xcopy exited with code 4.
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-10
      • 2014-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多