Ant 命令行帮助:iisvdir

发布于 2024-09-06 15:51:03 字数 1008 浏览 5 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

想你只要分分秒秒 2024-09-13 15:51:03
  1. iisvdir.vbs 是你所说的位置吗?
  2. 要让 CMD.EXE 运行命令,您需要使用 /C 开关。

例如:

cmd.exe echo Hello

...忽略参数并作为子 shell 运行另一个交互式命令提示符。

cmd.exe /c echo Hello

...运行“echo Hello”语句并立即返回。注意:如果您希望 cmd.exe 在运行该语句后继续以交互方式运行,则可以使用 /K(在构建脚本中通常不是一个好主意)。

你的命令:

cmd.exe cscript iisvdir.vbs /create etc.

...正在被解析,就好像你真的说:

cmd.exe /c reat etc.

这是因为 cmd.exe 有(与大多数 MS 命令行工具一样)怪异的命令行解析。

更新:这是 64 位操作系统吗?如果 Ant 是 32 位任务,那么它实际上会(静默地)在 C:\Windows\SysWOW64 中查找 cscript.exe 和 iisvdir.vbs。他们在吗?如果没有,您应该使用C:\Windows\SysNative。在 32 位任务中,它是真实的 C:\Windows\System32 目录的别名。

  1. Is iisvdir.vbs where you say it is?
  2. To get CMD.EXE to run a command, you need to use the /C switch.

For example:

cmd.exe echo Hello

...ignores the parameters and runs another interactive command prompt as a subshell.

cmd.exe /c echo Hello

...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:

cmd.exe cscript iisvdir.vbs /create etc.

...is getting parsed as if you'd really said:

cmd.exe /c reat etc.

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 use C:\Windows\SysNative. In a 32-bit task, this is aliased to the real C:\Windows\System32 directory.

溺ぐ爱和你が 2024-09-13 15:51:03

我不知道这是否是您问题的原因,但我注意到您对

不确定这是否有帮助,但可以为您指明正确的方向。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文