首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Psake、Powershell和Wix

Psake、Powershell和Wix
EN

Stack Overflow用户
提问于 2009-11-18 06:43:38
回答 2查看 1.2K关注 0票数 2

我有下面的函数作为我的psake构建的一部分。在执行构建时,Candle.exe会抛出此错误:

.\Build\Packages\WixWeb\bin\WixIIsExtension.dll‘:警告candle.exe:'ext CNDL1098不是有效的命令行参数。

我认为这是我传递命令行参数的方式的问题,但我无论如何也找不到它。

powershell的猴子有什么建议吗?

代码语言:javascript
复制
function buildMsi($build_dir, $template, $directory) { 
    "Building Msi" 
    "Build Folder: $build_dir"
    "Wix Template: $template"
    "Website: $directory"

    $wixXml = [xml](Get-Content $template)
    $namespaceManager = New-Object Xml.XmlNamespaceManager($wixXml.PSBase.NameTable)
    $namespaceManager.AddNamespace("wi", "http://schemas.microsoft.com/wix/2006/wi")
    $components = $wixXml.Wix.Fragment.ComponentGroup

    WalkDirectory $wixXml.PSBase.SelectSingleNode("/wi:Wix/wi:Fragment/wi:DirectoryRef", $namespaceManager) $directory
    $wixXml.Save("$build_dir\WebContent.wxs")

    .\Build\WixWeb\bin\Candle.exe """-dProductName=Foo""`
         ""-dVersion=1.0.0.0""`
         ""-dProductID=0cd64670-5769-4e34-8b21-c6242e7ca5a2""`
         ""-dUpgradeCode=307601e9-4eea-4b5c-938a-354115d5c419""`
         ""-dAppPool=FooAppPool""`
         ""-dInstallDirectory=Foo""`
         ""-dWebAppDirectoryComponentId=CF57E626-1E95-4a89-A0E9-C1AD03C51B12""`
         ""-dIIsAppPoolComponentId=D9138380-19B3-4123-9E22-AB2994B1024B""`
         ""-dIIsWithAppPoolSettingsComponentId=02ca3f08-a1e8-48a3-b4d7-6f5f67c61b96""`
         ""-dIIsWithoutAppPoolSettingsComponentId=d97791b0-f597-46c6-b159-541817527453""`
         ""-ext "".\Build\WixWeb\bin\WixIIsExtension.dll""""`
         ""-ext "".\Build\WixWeb\bin\WixUIExtension.dll""""`
         "".\Build\WixWeb\Shell.wxs""`
         "".\Build\stage\WebContent.wxs"" "

}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-11-18 06:55:27

尝试将内部双引号替换为单引号,如下所示:

代码语言:javascript
复制
.\Build\WixWeb\bin\Candle.exe " ""-dProductName=Foo"" `
     ""-dVersion=1.0.0.0"" `
     ""-dProductID=0cd64670-5769-4e34-8b21-c6242e7ca5a2"" `
     ""-dUpgradeCode=307601e9-4eea-4b5c-938a-354115d5c419"" `
     ""-dAppPool=FooAppPool"" `
     ""-dInstallDirectory=Foo"" `
     ""-dWebAppDirectoryComponentId=CF57E626-1E95-4a89-A0E9-C1AD03C51B12"" `
     ""-dIIsAppPoolComponentId=D9138380-19B3-4123-9E22-AB2994B1024B"" `
     ""-dIIsWithAppPoolSettingsComponentId=02ca3f08-a1e8-48a3-b4d7-6f5f67c61b96"" `
     ""-dIIsWithoutAppPoolSettingsComponentId=d97791b0-f597-46c6-b159-541817527453"" `
     ""-ext '.\Build\WixWeb\bin\WixIIsExtension.dll'"" `
     ""-ext '.\Build\WixWeb\bin\WixUIExtension.dll'"" `
     "".\Build\WixWeb\Shell.wxs"" `
     "".\Build\stage\WebContent.wxs"" "

此外,如果您使用`“正确地转义双引号(反引号后跟双引号),您可能会发现更容易;脚本也可能更健壮。然后,代码示例将变成:

代码语言:javascript
复制
.\Build\WixWeb\bin\Candle.exe " `"-dProductName=Foo`" `
 `"-dVersion=1.0.0.0`" `
 `"-dProductID=0cd64670-5769-4e34-8b21-c6242e7ca5a2`" `
 `"-dUpgradeCode=307601e9-4eea-4b5c-938a-354115d5c419`" `
 `"-dAppPool=FooAppPool`" `
 `"-dInstallDirectory=Foo`" `
 `"-dWebAppDirectoryComponentId=CF57E626-1E95-4a89-A0E9-C1AD03C51B12`" `
 `"-dIIsAppPoolComponentId=D9138380-19B3-4123-9E22-AB2994B1024B`" `
 `"-dIIsWithAppPoolSettingsComponentId=02ca3f08-a1e8-48a3-b4d7-6f5f67c61b96`" `
 `"-dIIsWithoutAppPoolSettingsComponentId=d97791b0-f597-46c6-b159-541817527453`" `
 `"-ext '.\Build\WixWeb\bin\WixIIsExtension.dll'`" `
 `"-ext '.\Build\WixWeb\bin\WixUIExtension.dll'`" `
 `".\Build\WixWeb\Shell.wxs`" `
 `".\Build\stage\WebContent.wxs`" "

不过,YMMV。

票数 2
EN

Stack Overflow用户

发布于 2020-11-17 05:26:01

我遇到了类似的问题,最终得到了问题所在。在powershell命令中,用空格分隔的每个参数也应被视为单独的参数

如果这是您用cmd编写原始命令行

代码语言:javascript
复制
.\Build\WixWeb\bin\Candle.exe ^
   -dProductName=Foo ^
   -dVersion=1.0.0.0 ^
   -dProductID=0cd64670-5769-4e34-8b21-c6242e7ca5a2 ^
   -ext .\Build\WixWeb\bin\WixIIsExtension.dll ^
   .\Build\stage\WebContent.wxs

你可以看到参数-dProductName=Foo是一个参数,但是当我们看一下.\Build\WixWeb\bin\WixIIsExtension.dll,,-ext,.\Build\WixWeb\bin\WixIIsExtension.dll,我们可以看到参数名称和值是分开的,所以这是两个独立的参数,应该作为两个字符串传递给candle.exe,而不是单个字符串。-ext是一个位置参数,它的值应该在参数标记之后。

正确的版本:

代码语言:javascript
复制
.\Build\WixWeb\bin\Candle.exe " `"-dProductName=Foo`" `
 `"-dVersion=1.0.0.0`" `
 `"-dProductID=0cd64670-5769-4e34-8b21-c6242e7ca5a2`" `
 `"-ext`" `
 `".\Build\WixWeb\bin\WixIIsExtension.dll'`" `
 `".\Build\stage\WebContent.wxs`" "
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1752405

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档