开发者

Relative paths in visual studio command-line file directory

I'm writing a post build event for visual studio project.

I have:

java -jar "$(ProjectDir)..\Tools\开发者_如何学编程closure_compiler.jar"

but it turns out to be after compiled:

"D:\Projects\Source\Proj.Web\..\Tools\closure_compiler.jar"

which is an invalid directory, it just appends the dots. My problem is that I want to go back up 1 directory. The absolute file path is:

"D:\Projects\Source\Tools\closure_compiler.jar"

The full event is:

java -jar "$(ProjectDir)..\Tools\closure_compiler.jar" --js "$(ProjectDir)Scripts\*.debug.js" --js_output_file "$(ProjectDir)Scripts\script-bundle.min.js"

The error is:

Error   24  The command "java -jar "D:\Projects\Xormis\trunk\Source\Xormis.Web\..\Tools\closure_compiler.jar" --js "D:\Projects\Xormis\trunk\Source\Xormis.Web\Scripts\*.debug.js" --js_output_file "D:\Projects\Xormis\trunk\Source\Xormis.Web\Scripts\script-bundle.min.js"" exited with code 1.  Xormis.Web


Here's a possible workaround for this. You just need to convert the relative path to an absolute one. If visual studio can handle regular command prompt commands with command extensions, this may work:

set ProjectDir=$(ProjectDir)
java -jar "%ProjectDir:~0,-9%Tools\closure_compiler.jar"

pushd $(ProjectDir)
cd ..
set ClosureCompiler=%CD%\Tools\closure_compiler.jar
popd
java -jar "%ClosureCompiler%"

You may need to tweak these to fit your needs.


The solution folder is typically one above the project directory, so give this a shot:

$(SolutionDir)\Tools\closure_compiler.jar

If that doesn't work, check out the full list of available macros. Maybe there's something else that'll come close.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜