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 "
This worked. I tested this in AVR Studio 6.1, which uses a Visual Studio Shell.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…