后期构建步骤中放置双引号

后期构建步骤中放置双引号

本文介绍了如何在 VS2010 后期构建步骤中放置双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 VS2010 中创建一个构建后文件复制步骤,它在路径宏具有嵌入空间时处理它们.我试过用双引号将复制命令括起来,但是如果 $(SolutionDir) 包含空格,则在调用复制时出现错误.错误消息中的回显命令行不显示双引号.

I'm trying to create a post build file copy step in VS2010 which handles path macros when they have embedded spaces. I've tried surrounding the copy commands in double quotes but I get error from when copy is invoked if $(SolutionDir) contains a space. the echoed command line in the error message does not show the double quotes.

copy "$(SolutionDir)$(Configuration)*" "$(TargetDir)"

我也分别尝试了 """ 但是这两个都会导致 2 个字符的转义序列出现在回显的命令行中?如何正确转义 a在构建步骤中使用双引号?

I also tried separately " and "" but both of these cause the 2 character escape sequence to appear in the echoed command line? How does one properly escape a double quote in a build step?

推荐答案

我在 Visual Studio 中使用双引号和预构建事件命令时遇到问题.我已经看到了这个问题的批处理文件解决方案,但似乎批处理文件不能解决所有问题并且不优雅.我发现解决方案是在结束双引号前加一个空格.详情如下.

I was having trouble using double quotes with a pre-build event command in Visual Studio. I have seen the batch file solutions to this problem, but it seems a batch file would not solve all problems and is not elegant. I found the solution was to put a space before the closing double quote. The details are as follows.

以下命令有效,但不支持路径中的空格:

The following command worked, but would not support spaces in the path:

subwcrev $(SolutionDir) $(SolutionDir)subwcrev_template.txt $(SolutionDir)version.h

我几乎无法控制其他开发人员将解决方案放置在何处,因此我必须支持路径中的空格.尝试在路径周围使用引号来支持空格,我想出了以下命令.它总是失败.

I have little control over where other developers will place the solution, so I had to support spaces in the path. Trying to use quotes around paths to support spaces, I came up with the following command. It always fails.

subwcrev "$(SolutionDir)" "$(SolutionDir)subwcrev_template.txt" "$(SolutionDir)version.h"

几乎是偶然,我找到了解决方案,在路径的最后一个字符和双引号之间放一个空格.

Almost by accident, I found the solution, put a space between the last character of the path and the double quote.

subwcrev "$(SolutionDir) " "$(SolutionDir)subwcrev_template.txt " "$(SolutionDir)version.h "

这奏效了.我在使用 Visual Studio Shell 的 AVR Studio 6.1 中对此进行了测试.

This worked. I tested this in AVR Studio 6.1, which uses a Visual Studio Shell.

这篇关于如何在 VS2010 后期构建步骤中放置双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:17