Thank you for your replay!
The code
so strange behavior....
Below is my code:
The code
project.MinimalCustomDrawing = true;
have fixed the situation.... Now the msi works without exception.so strange behavior....
Below is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Linq;
using System.Xml.XPath;
using WixSharp;
using WixSharp.CommonTasks;
using WixSharp.Forms;
using WixSharp.UI.Forms;
// https://wixsharp.codeplex.com/releases/view/624868
// https://wixsharp.codeplex.com/SourceControl/latest#readme.txt
namespace MsiAppFormTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btDeploy_Click(object sender, EventArgs e)
{
Compiler.WixLocation = @"some_location2\_msi\WixSharp.1.0.40.0\Wix_bin\bin\";
var general = new Feature("General files", true, false);
var modules = new Feature("Modules files", true, true);
var modulett0 = new Feature("t0Module", true, true);
var modulet1 = new Feature("t1Module", true, true);
var modulet2 = new Feature("t2Module", true, true);
var modulet2 = new Feature("t3Module", true, true);
var modulet4 = new Feature("t4Module", true, true);
var modulet5 = new Feature("t5Module", false, true);
var modulet6 = new Feature("t6Module", false, true);
var modulet7 = new Feature("t7odule", false, true);
modules.Add(modulet0);
modules.Add(modulet1);
modules.Add(modulet2);
modules.Add(modulet3);
modules.Add(modulet4);
modules.Add(modulet5);
modules.Add(modulet6);
modules.Add(modulet7);
general.Add(modules);
ManagedProject project = new ManagedProject("agent",
new Property("RURL", @"https://url.com") { IsDeferred = true },
new Dir(@"%ProgramFiles%\agent",
new File(modulet0, @"some_location\t0.dll"),
new File(modulet1, @"some_location\t1.dll"),
new File(modulet2, @"some_location\t2.dll"),
new File(modulet3, @"some_location\t3.dll"),
new File(modulet4, @"some_location\t4.dll"),
#region MySql
new File(modulet5, @"some_location\t51.dll"),
new File(modulet5g, @"some_location\t52.dll"),
#endregion
#region oracle
new File(modulet6, @"some_location\t6.dll"),
new Dir(modulet6, @"OraClient.x64",
new File(modulet6, @"some_location\OraClient.x64\oci.dll"),
new File(modulet6, @"some_location\OraClient.x64\ociw32.dll"),
new File(modulet6, @"some_location\OraClient.x64\orannzsbb10.dll"),
new File(modulet6, @"some_location\OraClient.x64\oraocci10.dll"),
new File(modulet6, @"some_location\OraClient.x64\oraociei10.dll")),
new Dir(modulet6, @"OraClient.x86",
new File(modulet6, @"some_location\OraClient.x86\oci.dll"),
new File(modulet6, @"some_location\OraClient.x86\ociw32.dll"),
new File(modulet6, @"some_location\OraClient.x86\orannzsbb10.dll"),
new File(modulet6, @"some_location\OraClient.x86\oraocci10.dll"),
new File(modulet6, @"some_location\OraClient.x86\oraociei10.dll")),
#endregion
#region ftp
new File(modulet7, @"some_location\t7.dll"),
new File(modulet7, @"some_location\t71.dll"),
new File(modulet7, @"some_location\t72.dll"),
#endregion
new Dir(general, @"x64", new File(@"some_location\x64\SQLite.Interop.dll")),
new Dir(general, @"x86", new File(@"some_location\x86\SQLite.Interop.dll")),
new File(general, @"some_location\a0.db"),
new File(general, @"some_location\a1.pos"),
new File(general, @"some_location\a2.json"),
new File(general, @"some_location\agent.config"),
new File(general, @"some_location\System.Data.SQLite.dll"),
new File(general, @"some_location\a5.dll"),
new File(general, @"some_location\agent.exe"),
new File(general, @"some_location\u0.config"),
new File(general, @"some_location\u1.exe"))
);
project.DefaultFeature = general;
project.DefaultFeature.Children.Add(modulet0);
project.DefaultFeature.Children.Add(modulet1);
project.DefaultFeature.Children.Add(modulet2);
project.DefaultFeature.Children.Add(modulet3);
project.DefaultFeature.Children.Add(modulet4);
project.DefaultFeature.Children.Add(modulet5);
project.DefaultFeature.Children.Add(modulet6);
project.DefaultFeature.Children.Add(modulet7);
//if( Environment.GetEnvironmentVariable("buid_as_64") != null ) project.Platform = Platform.x64; // работает НЕвсегда....
if( IntPtr.Size == 8 ) project.Platform = Platform.x64;
project.GUID = new Guid("0c47a0be-437d-4ab6-883a-f0ecc38ddbff");
project.PreserveTempFiles = true;
//project.MinimalCustomDrawing = true; // <-------------------------- fix the problem
project.ManagedUI = new ManagedUI();
project.ManagedUI.InstallDialogs.Add<WelcomeDialog>()
.Add<LicenceDialog>()
.Add<InstallDirDialog>()
.Add<FeaturesDialog>()
.Add<CustFormSrvAdr>()
.Add<ProgressDialog>()
.Add<ExitDialog>();
project.ManagedUI.ModifyDialogs.Add<FeaturesDialog>()
.Add<ProgressDialog>()
.Add<ExitDialog>();
project.AfterInstall += Project_AfterInstall;
Compiler.BuildMsi(project);
MessageBox.Show("Completed successfully!", "Status");
Close();
}
private static void Project_AfterInstall(SetupEventArgs e)
{
if( e.IsInstalling ) {
string strSrvUrl = e.Session.Property("URL");
string configFile = System.IO.Path.Combine(e.InstallDir, "Agent.config");
UpdateAsXml(configFile, strSrvUrl);
}
else if( e.IsUninstalling ) {
try {
System.IO.Directory.Delete(e.InstallDir, true);
}
catch { /*log error if required*/ }
}
}
static public void UpdateAsXml(string configFile, string strSrvUrl)
{
var xDoc = XDocument.Load(configFile);
xDoc.XPathSelectElement("//configuration/appSettings/add[@key='bla-bla']").Attribute("value").Value = strSrvUrl;
xDoc.Save(configFile);
}
}
}