visual-studio - Visual Studio 构建后事件中的路径

标签 visual-studio command-line command-line-arguments robocopy

我有以下问题:因为 Visual Studio 无法处理链引用,所以我需要将所有“链引用”-DLL 复制到程序的 bin 文件夹中。为此,我使用 Robocopy。

唯一的问题是,我在 Visual Studio 构建后事件中输入的命令行分割不正确。

ROBOCOPY "$(TargetDir)" "$(SolutionDir)Map\bin\$(ConfigurationName)\" *.dll /LOG:RCPY.log

这是我的构建事件。我现在得到的内容如下:

Gestartet: Fri Jul 06 15:40:30 2012

Quelle : F:\Sicherung\Visual Studio\Projects\Map\Core\Core.GUI\bin\Release\ F:\Sicherung\Visual\
Ziel : F:\Sicherung\Visual Studio\Projects\Map\Core\Core.GUI\bin\Release\Studio\Projects\Map\Map\bin\Release\

Dateien : *.dll

Optionen: /COPY:DAT /R:1000000 /W:30

为什么,它在第二个路径/参数中“Visual Studio”的空白处将其分割。 我尝试了所有带有引号的内容,但要么 Robocopy 没有执行(至少日志文件没有被覆盖),要么我得到了显示的日志条目...

Visual Studio 显示:

The command ... exited with code 16

这意味着存在 fatal error ,主要是由无效路径引起的。

最佳答案

与 xcopy 不同,robocopy 将\"视为转义字符,如 http://ss64.com/nt/robocopy.html 中所述:

If either the source or desination are a "quoted long foldername" do not include a trailing backslash as this will be treated as an escape character, i.e. "C:\some path\" will fail but "C:\some path\" or "C:\some path." or "C:\some path" will work.

由于尾​​随反斜杠已包含在构建后宏中,因此您需要在源参数和目标参数末尾添加第二个反斜杠或句点:

ROBOCOPY "$(TargetDir)." "$(SolutionDir)Map\bin\$(ConfigurationName)\." *.dll /LOG:RCPY.log

我建议添加句点,因为这会消除转义字符而不是解决它。

关于visual-studio - Visual Studio 构建后事件中的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11363616/

相关文章:

mysql - 是否可以将 EntityFramework 与 MemSQL 一起使用?

c - 在 visual studio 的命令行中以 C 的形式作为标准输入文件

c - 格式指定类型为'char *',但参数的类型为'char'[-Wformat]

linux - Bash 引号禁止转义

c - 查找 C 程序的输出

c++ - 在 C++ 中使用命令行参数的 cgi 脚本

visual-studio - 无法使用数据源配置向导在Web项目中添加数据源

c# - 我丢失了 Visual Studio C# 2008 的设计 View

visual-studio - 如何阻止 Visual Studio 创建 pdb 调试文件夹?

c++ - 如何缩短命令行命令?