Wix Psake,Powershell&;巫师

Wix Psake,Powershell&;巫师,wix,powershell-2.0,psake,Wix,Powershell 2.0,Psake,我有以下功能作为我的诗篇构建的一部分。生成正在执行Candle.exe时引发以下错误: candle.exe:警告CNDL1098:“ext.\Build\Packages\WixWeb\bin\WixIIsExtension.dll”不是有效的命令行参数 我认为这是我传递命令行参数的方式的一个问题,但我一辈子都无法解决这个问题 有什么建议吗 function buildMsi($build_dir, $template, $directory) { "Building Msi"

我有以下功能作为我的诗篇构建的一部分。生成正在执行Candle.exe时引发以下错误:

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

我认为这是我传递命令行参数的方式的一个问题,但我一辈子都无法解决这个问题

有什么建议吗

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"" "

}

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

.\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"" "
此外,如果使用`(backtick后跟doublequote)正确地转义双引号,您可能会发现更容易;脚本也可能更健壮。代码示例将变成:

.\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。

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

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

.\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是一个参数,但当我们查看-ext.\Build\WixWeb\bin\WixIIsExtension.dll时,我们可以看到参数名称和值是分开的,因此这是两个分开的参数,应该作为两个字符串而不是单个字符串传递给candle.exe。 -ext是一个位置参数,其值应位于参数标记后面

正确版本:

.\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`" "

你的意思是在-ext行的末尾有四个“s”吗?在我看来,开头有四个引号。使用单引号还是转义双引号?或者两者都有?这很奇怪,它就像是删除了-ext参数的-off。根据您可以删除路径和.dll扩展名,因为扩展名与Candle位于同一位置。我认为缺少-from-ext的错误输出是出于设计。参数的名称为“ext”而不是“-ext”;此外,如果PowerShell正在执行此操作,我希望它会在第一个-d参数上出错。尝试了这两个参数,删除这两行允许它执行,但我的wix scrit显然失败了。。8)