Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

candle.exe : error CNDL0125 when building bootstrapper application from existing msi and add bootstrapper variable #902

Closed
noctis0430 opened this issue Aug 24, 2020 · 5 comments

Comments

@noctis0430
Copy link
Contributor

noctis0430 commented Aug 24, 2020

I got the following error when trying to build the bootstrapper application

candle.exe : error CNDL0125 : The extension 'Microsoft.Tools.WindowsInstallerXml.Extensions.BalCompiler' uses the same xml schema namespace, 'http://schemas.microsoft.com/wix/BalExtension', as previously loaded extension 'Microsoft.Tools.WindowsInstallerXml.Extensions.BalCompiler'. Please either remove one of the extensions or rename the xml schema namespace to avoid the collision.

The issue is reproducible from the WixBootstrapper project in the samples. The following sample codes is the (overly) simplified codes that demonstrate the issue.

// Runs OK when build msi on runtime.
//var productMsi = BuildMainMsi()

// Failed with error when using pre-built msi.
var productMsi = @"D:\My Product.msi"

var bootstrapper = new Bundle("My Product", new MsiPackage(productMsi));
bootstrapper.Version = Tasks.GetVersionFromFile(productMsi)
// Error won't occur when this is disabled.
bootstrapper.Variables = new[] { new Variable("Foo", "Bar") };

var setup = bootstrapper.Build("app_setup");

WixSharp version: 1.14.7.0

The difference is that when building the .msi during the runtime, bootstrapper application build successfully, but that's not the case when using a pre-built .msi file. In both cases, WixExtension.Bal is being included twice into the Bundle instance, once during the instantiation, the other during calls to Variable.Process() at Bundle.ToXml(). Both case generated the same .wxs and looks OK (no duplication of http://schemas.microsoft.com/wix/BalExtension).

@oleg-shilo oleg-shilo added the bug label Aug 26, 2020
@oleg-shilo
Copy link
Owner

Thank you for reporting it.
Will have a look.
But in a mean time, can you please see if problem exists if you generate and execute the build batch file with bootstrapper.BuildCmd(...). Most likely it does and you can address it by editing the cmd before the execution.

@noctis0430
Copy link
Contributor Author

Problem still exists when executing the build batch file generated with bootstrapper.BuildCmd(...). Unfortunately I'm not familiar with wix command and not sure what to edit to make it work correctly.

Is there any info that I can provide to help investigate this issue?

@oleg-shilo
Copy link
Owner

Nothing comes to my mind.
My immediate impression is that the namespace is injected in the wxs twice. But you are saying the same xml can be build under different scenario.

Then may be the extension dll is passed to the candle twice. But you saw the cmd file.... I am guessing there is no duplication there neither.

Will need to look at it and give it some thinking.

@oleg-shilo
Copy link
Owner

OK, the problem is caused by the flaw in the candle command generation algorithm. If you execute bootstrapper.BuildCmd(...) you will see that the produced batch file has the line -ext "C:\Program Files (x86)\WiX Toolset v3.11\bin\WixBalExtension. injected twice.

Thus your work around until the fix is available it to edit the batch file by removing the duplicated extension and then execute the batch file manually.

In a mean time I will have a look at the actual cayuse of the problem.

oleg-shilo added a commit that referenced this issue Aug 27, 2020
…application from existing msi and add bootstrapper variable
@oleg-shilo
Copy link
Owner

Fixed. Will be available in the very next release. Aiming on this weekend.
The problem was caused by the Distinct algorithm failing in case of path containing environment variables:

// before
foreach (string dll in project.WixExtensions.Distinct())
    extensionDlls += " -ext \"" + dll + "\""; 

// after
foreach (string dll in project.WixExtensions.DistinctBy(x => x.ExpandEnvVars()))
    extensionDlls += " -ext \"" + dll + "\"";

oleg-shilo added a commit that referenced this issue Aug 29, 2020
* - Issue #902: candle.exe : error CNDL0125 when building bootstrapper application from existing msi and add bootstrapper variable
* Issue #862: I can't seem to get it working
* Issue #900: Preserve messageType value for ExternalUI setup with Custom Actions
* Merge pull request #899 from Q-Sharp/master
* Added Condition Net48_Installed
* Implemented/fixed `WixEntity.ComponentCondition`. Triggered by "How to add Condition to ODBCDataSource #896 "
* Issue #894: LicenseBootstrapperApplication do not add payloads in case of rtf license
* - Added `Process.StartElevated` extension method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants