English 中文(简体)
Psake, Powershell & Wix
原标题:

I have the below function as a part of my psake build. When the build is executing Candle.exe throws this error:

candle.exe : warning CNDL1098: ext .BuildPackagesWixWebinWixIIsExtension.dll is not a valid command line argument.

I think this is a problem with the way I am passing command line args but I cannot for the life of me figure it out.

Any powershell monkeys have suggestions?

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_dirWebContent.wxs")

    .BuildWixWebinCandle.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 "".BuildWixWebinWixIIsExtension.dll""""`
         ""-ext "".BuildWixWebinWixUIExtension.dll""""`
         "".BuildWixWebShell.wxs""`
         "".BuildstageWebContent.wxs"" "

}
最佳回答

Try replacing your inner double quotes with single quotes, like so:

.BuildWixWebinCandle.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  .BuildWixWebinWixIIsExtension.dll "" `
     ""-ext  .BuildWixWebinWixUIExtension.dll "" `
     "".BuildWixWebShell.wxs"" `
     "".BuildstageWebContent.wxs"" "

Futhermore, you might find it easier if you escape your double quotes correctly using `" (backtick followed by doublequote); the script might be more robust, too. The code sample would then become:

.BuildWixWebinCandle.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  .BuildWixWebinWixIIsExtension.dll `" `
 `"-ext  .BuildWixWebinWixUIExtension.dll `" `
 `".BuildWixWebShell.wxs`" `
 `".BuildstageWebContent.wxs`" "

YMMV, though.

问题回答

I faced similar issue and eventually got what the problem. Every parameter separated with a space should be also treated as separate argument in powershell command

If this is an original command line that you write in cmd

.BuildWixWebinCandle.exe ^
   -dProductName=Foo ^
   -dVersion=1.0.0.0 ^
   -dProductID=0cd64670-5769-4e34-8b21-c6242e7ca5a2 ^
   -ext .BuildWixWebinWixIIsExtension.dll ^
   .BuildstageWebContent.wxs

You could see that argument -dProductName=Foo is one argument but when we take a look at -ext .BuildWixWebinWixIIsExtension.dll we could see that argument name and value are separated therefore these are 2 separate arguments that should be passed to candle.exe as 2 strings instead of single string. -ext is a positional argument and its value should be next after the argument-marker.

Correct version:

.BuildWixWebinCandle.exe " `"-dProductName=Foo`" `
 `"-dVersion=1.0.0.0`" `
 `"-dProductID=0cd64670-5769-4e34-8b21-c6242e7ca5a2`" `
 `"-ext`" `
 `".BuildWixWebinWixIIsExtension.dll `" `
 `".BuildstageWebContent.wxs`" "




相关问题
3rd party Wix libraries

I am just getting started with Wix. I see there there a several libraries included with the default Wix install. I also see that users can create their own libraries(wixlibs). Are there any 3rd ...

Psake, Powershell & Wix

I have the below function as a part of my psake build. When the build is executing Candle.exe throws this error: candle.exe : warning CNDL1098: ext .BuildPackagesWixWebinWixIIsExtension.dll ...

wix custom dialog for config edit

hi i m trying make a setup msi for my application with wix v3 I have a problem about this task; I need a user input that will be stored in my application s config file (for example i need a dialog for ...

Closing an application using WiX

In creating my WiX installer I have run into an issue when trying to close an application before installing the upgrade. Below is an example of how I am attempting to do this. <util:...

Conditional uninstall of previous version in Wix

I m doing an installer for an software used for debugging embedded ARM cores (OpenOCD) and this installer automatically removes the previous versions - that s simple. However, sometimes that would be ...

热门标签