Ant 命令行帮助:iisvdir
在 Visual Studio 中编译 .net 应用程序之前,我尝试从 ant 脚本执行 iisvdir 来清理并创建虚拟目录。我在一个构建服务器上遇到了一些奇怪的错误,但另一个正在运行脚本没有任何问题。
<exec dir="${SYSTEM32}" executable="cscript" failonerror="true">
<arg line='iisvdir.vbs /create "Default Web Site" ${RS_VIRTUAL_DIR} "${env.WORKSPACE}"'/>
</exec>
结果:
[exec] Microsoft (R) Windows Script Host Version 5.6
[exec] Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
[exec]
[exec] Input Error: Can not find script file "c:\windows\system32\iisvdir.vbs".
然后
<exec dir="${SYSTEM32}" executable="cmd" failonerror="true">
<arg line='cscript iisvdir.vbs /create "Default Web Site" ${RS_VIRTUAL_DIR} "${env.WORKSPACE}"'/>
</exec>
结果
[exec] 'reate' is not recognized as an internal or external command,
[exec] operable program or batch file.
有人能帮我找出可能出了什么问题吗?
I'm trying to execute iisvdir from an ant script to clean and create a virtual directory before I compile my .net app in Visual Studio. I am running into a couple of strange errors one one build server, but another is running the script without any problem.
<exec dir="${SYSTEM32}" executable="cscript" failonerror="true">
<arg line='iisvdir.vbs /create "Default Web Site" ${RS_VIRTUAL_DIR} "${env.WORKSPACE}"'/>
</exec>
Results in:
[exec] Microsoft (R) Windows Script Host Version 5.6
[exec] Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
[exec]
[exec] Input Error: Can not find script file "c:\windows\system32\iisvdir.vbs".
And then
<exec dir="${SYSTEM32}" executable="cmd" failonerror="true">
<arg line='cscript iisvdir.vbs /create "Default Web Site" ${RS_VIRTUAL_DIR} "${env.WORKSPACE}"'/>
</exec>
Results in
[exec] 'reate' is not recognized as an internal or external command,
[exec] operable program or batch file.
Can someone help me figure out what might be wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
例如:
...忽略参数并作为子 shell 运行另一个交互式命令提示符。
...运行“echo Hello”语句并立即返回。注意:如果您希望 cmd.exe 在运行该语句后继续以交互方式运行,则可以使用 /K(在构建脚本中通常不是一个好主意)。
你的命令:
...正在被解析,就好像你真的说:
这是因为 cmd.exe 有(与大多数 MS 命令行工具一样)怪异的命令行解析。
更新:这是 64 位操作系统吗?如果 Ant 是 32 位任务,那么它实际上会(静默地)在 C:\Windows\SysWOW64 中查找 cscript.exe 和 iisvdir.vbs。他们在吗?如果没有,您应该使用
C:\Windows\SysNative
。在 32 位任务中,它是真实的C:\Windows\System32
目录的别名。For example:
...ignores the parameters and runs another interactive command prompt as a subshell.
...runs the "echo Hello" statement and returns immediately. Note: You can use /K if you want cmd.exe to continue running interactively after running the statement (not usually a good idea in a build script).
Your command:
...is getting parsed as if you'd really said:
This is because cmd.exe has (as with most MS command line tools) freaky command line parsing.
Update: Is this a 64-bit OS? If Ant is a 32-bit task, then it'll actually (silently) be looking in
C:\Windows\SysWOW64
for cscript.exe and iisvdir.vbs. Are they there? If not, you should useC:\Windows\SysNative
. In a 32-bit task, this is aliased to the realC:\Windows\System32
directory.我不知道这是否是您问题的原因,但我注意到您对
不确定这是否有帮助,但可以为您指明正确的方向。
I don't know if it's the cause of your problems but I notice that you are using a single quote (') for <arg line='. All the examples I've seen use a double quote (") I know you are enclosing items with spaces in double quotes so it may be necessary to escape them out? Perhaps moving the code into a batch file which you can test before running via Ant?
Not sure if this will help but could point you in the right direction.