我有以下问题:因为 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/