简体   繁体   English

如何将参数传递给预构建命令行?

[英]How to pass arguments to the pre-build command line?

How do I pass arguments to a Pre-build event command line in Visual Studio 2013? 如何在Visual Studio 2013中将参数传递到预生成事件命令行?

I can run the program with "C:\\foo\\bar.exe" but can't pass arguments to my program. 我可以使用"C:\\foo\\bar.exe"运行该程序,但是无法将参数传递给我的程序。 I have tryed difference combinations like. 我尝试了类似的差异组合。

1) 1)

"c:\\foo\\bar.exe" “ c:\\ foo \\ bar.exe”

"c:\\sourcepath\\" “ c:\\ sourcepath \\”

"c:\\targetpath" “ c:\\ targetpath”

2) 2)

"c:\\foo\\bar.exe -c:\\sourcepath\\ c:\\targetpath" “ c:\\ foo \\ bar.exe -c:\\ sourcepath \\ c:\\ targetpath”

3) 3)

"c:\\foo\\bar.exe c:\\sourcepath\\ c:\\targetpath" “ c:\\ foo \\ bar.exe c:\\ sourcepath \\ c:\\ targetpath”

4) 4)

"c:\\foo\\bar.exe -c:\\sourcepath\\, c:\\targetpath" “ c:\\ foo \\ bar.exe -c:\\ sourcepath \\,c:\\ targetpath”

5) 5)

"c:\\foo\\bar.exe c:\\sourcepath\\, c:\\targetpath" “ c:\\ foo \\ bar.exe c:\\ sourcepath \\,c:\\ targetpath”

Maybe it's not possible? 也许不可能吗? I can't find anything in the doc MSDN . 我在文档MSDN中找不到任何内容。

Assuming I'm understanding correctly that you want variables passed automatically when you compile and run your project, it is possible in the project settings. 假设我正确理解了您希望在编译和运行项目时自动传递变量的可能性,那么可以在项目设置中进行。

Go to Project > Properties > Configuration Properties 转到项目>属性>配置属性

Fill out the Command Arguments field with whatever you want to automatically pass when you run it in MSVS. 使用在MSVS中运行时要自动传递的内容填写“命令参数”字段。

Try this: 尝试这个:

  1. "c:\\foo\\bar.exe" c:\\sourcepath\\ c:\\targetpath “ c:\\ foo \\ bar.exe” c:\\ sourcepath \\ c:\\ targetpath

  2. "c:\\foo\\bar.exe" "c:\\sourcepath\\path with space" "c:\\targetpath" “ c:\\ foo \\ bar.exe”“ c:\\ sourcepath \\带有空格的路径”“ c:\\ targetpath”

You should not put all the command between quotes, use quotes for the executable and it is always recommended to use quotes for your arguments if they contain spaces. 您不应该将所有命令放在引号之间,对于可执行文件使用引号,并且如果参数中包含空格,则始终建议对引号使用引号。

Update: 更新:

As I told before, you must surround each path with quotes specially when they have spaces. 正如我之前所说的,当每个路径都带有空格时,必须特别用引号引起来。

Try this: 尝试这个:

"C:\\Program Files (x86)\\Mark Lagendijk\\WinLess\\WinLess.exe" "d:\\udvikling\\test_winless\\LESS\\factory\\" "D:\\Udvikling\\test_winless\\LESS" “ C:\\ Program Files(x86)\\ Mark Lagendijk \\ WinLess \\ WinLess.exe”“ d:\\ udvikling \\ test_winless \\ LESS \\ factory \\”“ D:\\ Udvikling \\ test_winless \\ LESS”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM