Visual Studio post-build事件中的路径

Sha*_*ade 6 command-line robocopy command-line-arguments visual-studio

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

唯一的问题是,我的命令行,我在Visual Studio后期构建事件中输入错误.

ROBOCOPY "$(TargetDir)" "$(SolutionDir)Map\bin\$(ConfigurationName)\" *.dll /LOG:RCPY.log
Run Code Online (Sandbox Code Playgroud)

这是我的构建活动.我现在得到的是:

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
Run Code Online (Sandbox Code Playgroud)

为什么,它会在第二个路径/参数中的"Visual Studio"的空白区域拆分它.我用引号尝试了一切,但是没有执行Robocopy(至少日志文件没有被覆盖)或者我得到了这个日志条目...

Visual Studio显示:

命令...退出代码16

这意味着存在致命错误,主要是导致无效路径.

Bra*_*adV 8

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

如果源或desination是"引用的long foldername",则不包括尾部反斜杠,因为这将被视为转义字符,即"C:\ some path \"将失败,但"C:\ some path \"或"C:\有些道路." 或"C:\某些路径"将起作用.

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

ROBOCOPY "$(TargetDir)." "$(SolutionDir)Map\bin\$(ConfigurationName)\." *.dll /LOG:RCPY.log
Run Code Online (Sandbox Code Playgroud)

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