Quantcast
Channel: wixsharp Discussions Rss Feed
Viewing all 1354 articles
Browse latest View live

New Post: How to chnage install directory from WPF Application

$
0
0
I am working on bootstrapper UI as my benchmark and created new UI in WPF.
When the "Install Directory " property is changed ,I have added it in Static variables so that it can be accessed in setup.cs file.
__
Here Data variables is my static Class .I filled the values in the main screen .
But Msi file is created before user filling values.

It will be beneficial to many users as lots of user required this functionality.
__
static public void Main(string[] args)
{
System.Windows.Forms.MessageBox.Show(DataVariables.installationFolder);


var productProj =
    new Project("My Product",
        new Dir(DataVariables.installationFolder +@"\My Company\My Product",
            new File("readme.txt")
            )
            ) { InstallScope = InstallScope.perMachine };
productProj.GUID = new Guid("6f330b47-2577-43ad-9095-1861bb258778");
string productMsi = productProj.BuildMsi();

//------------------------------------
var bootstrapper =
        new Bundle("My Product",                    
            new MsiPackage(productMsi) { Id = "MyProductPackageId", DisplayInternalUI = false });

System.Windows.Forms.MessageBox.Show(System.Reflection.Assembly.GetExecutingAssembly().Location.ToString());
bootstrapper.Version = new Version("1.0.0.0");
bootstrapper.UpgradeCode = new Guid("6f330b47-2577-43ad-9095-1861bb25889a");
bootstrapper.Application = new ManagedBootstrapperApplication("%this%"); // you can also use System.Reflection.Assembly.GetExecutingAssembly().Location
bootstrapper.PreserveTempFiles = true;
bootstrapper.Build();    
io.File.Delete(productMsi);
}

New Post: Scope PerUser and admin prompt

$
0
0
Hello,
can i set install scope to "perUser" and at the same time before starting instalation get UAC prompt dialog? I use bootstrapper project (EXE with 2 installations (.net and my application)). If i set perMachine i get UAC prompt dialog but software is installed to all users. I need to setup for current logged user but with UAC dialog for confirm admin privileges.

Thanks.

New Post: Scope PerUser and admin prompt

$
0
0
This is rather a WiX challenge not a Wix#. perMachine is the setting that triggers the UAC prompt. As far as I know MSI doesn't consider scenario when per-user install requires elevation.

Of course you can either build with Wix# your custom bootstrapper app (BA) that requires elevation while keeping per-user install model. This will achieve the desired behavior. You can also check in the first install as a Launch condition or in a OnLoad event if the user is an admin and fail the install with an instruction to restart the install as an admin.

However quite possible there is a work around within MSI/WiX that I am just not aware of. You can post this very same question to the Wix# GitHub board where currently Wix# is hosted. GitHub may have a wider WiX audience so there is a chance that someone will offer a hint.

New Post: Unistalling previous versions

$
0
0
I looked through the documentation and samples, but did not find any examples of uninstalling applications before installing a new one. The application is the same, with a new version number.

Can you point me to an example?

Thank you

New Post: Unistalling previous versions

$
0
0
Have a look at the upgrade sample.

New Post: Do you have an existing easy way to detect that the installation has failed?

$
0
0
Just wondering -- is there a way to detect a failed installation (while the installer is running)?

Eg, when I set the installation to perMachine, and the installation fails and the log points out that it's due to lack of Admin privileges, obviously I could make a utility that scans that log looking for any error. But as it is, it gives no obvious indication to your user and he clicks on "Finish" but realizes nothing got installed. I would like to throw up a message-box or enable a field on the last dialog.

Depending upon the particular machine, the user may get that UAC indication, but some configurations do not show that indication, or, the installation might fail for other reasons.

As always -- I deeply appreciate your work in building and supporting this great project. Thank you.

gratefully thine,

James Hurst
email: JamesH@Designforge.com

New Post: Do you have an existing easy way to detect that the installation has failed?

$
0
0
It is an interesting one. It's impossible to know from the CA where MSI creates the log file for the current session. Neither MSI nor WiX doesn't provide any API for that. However if one is using Wix# Managed UI then the location is always deterministic. Thus if you use Custom UI sequence VS template you will see the link label on the Setup exit dialog. This link points to the corresponding log file.

Though I am not sure why do you need to do anything for that at all. Both MSI native and Wix# ManagedUI are clearly reporting the success (or failure) of the installation.

New Post: Conditionally creating SqlDatabase only by initial Installation, not by Major Upgrade

$
0
0
How to add Condition for Component SqlDatabase in WixSharp?
My C# Code is following:
_project = new ManagedProject();
// -- Only single database is required.
        _project.SqlDatabases = new SqlDatabase[1];
        _project.SqlDatabases[0] = new SqlDatabase
        {
            Id = setting.Id,
            Server = setting.Server.Key,
            Database = setting.Database.Key,
            Instance = setting.Instance.Key,

            User = "SQLUser",
            CreateOnInstall = true,
            SqlScripts = new[] { new SqlScript("GenerateDatabase", ExecuteSql.OnInstall) },
            SqlStrings = new[]
            {
                new SqlString(DatabaseConstant.CreateSqlLoginAndUser, ExecuteSql.OnInstall)
            }
        };
And Wix *.wxs is following:
<Component Id="SqlDatabase1" Guid="3338faaa-8c9c-43c3-b5ac-3f73970b42ec" KeyPath="yes">
        <SqlDatabase Id="DATABASE_UNIQUED_IDENTIFIER" Database="[DATABASENAME]" Server="[SERVERADDRESS]" CreateOnInstall="yes" Instance="[SERVERINSTANCE]" User="SQLUser" xmlns="http://schemas.microsoft.com/wix/SqlExtension">
          <SqlString Id="SqlString" SQL=" SQL SCRIPT " ExecuteOnInstall="yes" />

          <SqlScript Id="GenerateDatabase" BinaryKey="GenerateDatabase" ExecuteOnInstall="yes" />
        </SqlDatabase>
      </Component>
I would appreciate an Example.

New Post: Conditionally creating SqlDatabase only by initial Installation, not by Major Upgrade

$
0
0
The condition element for SqlDatabase is not available directly so you need to insert it in the final XML:
project.WixSourceGenerated += document =>
{
    document.Root.FindSingle("SqlDatabase")
                 .Parent
                 .AddElement("Condition")
                 .SetValue("INSTALLING=\"yes\" AND UPGRADING=\"no\"");
};
In the code above I used dummy condition names INSTALLING and UPGRADING but you will need to find the real condition expression that constitutes "initial Installation, not by Major Upgrade"

New Post: Change id of binary generated by using ElevatedManagedAction

$
0
0
Hi,

When using elevatedmanagedaction in WixSharp, I get the following generated Wix file:

<CustomAction Id="Action2_SetJavaEnvironment" BinaryKey="Action2_SetJavaEnvironment_File" DllEntry="SetJavaEnvironment" Return="check" Impersonate="no" Execute="deferred" />
<CustomAction Id="Action3_RemoveJavaEnvironment" BinaryKey="Action2_SetJavaEnvironment_File" DllEntry="RemoveJavaEnvironment" Return="check" Impersonate="no" Execute="deferred" />

<Binary Id="Action2_SetJavaEnvironment_File" SourceFile="C:\Public\MergeModules\CustomActions.CA.dll" />
Is it possible to change the id of the binary node generated by creating an elevatedmanagedaction in WixSharp? I will also need to change the BinaryKey of the customaction nodes to match that new id.

Thanks!

New Post: Change id of binary generated by using ElevatedManagedAction

New Post: Conditionally creating SqlDatabase only by initial Installation, not by Major Upgrade

$
0
0
Thank you for your reply.
I have implemented your suggestion and it works fine by Major Upgrade.
But now by new Installation, the SqlDatabase not installed too.
I don’t know how to get which Condition should be on first position:
INSTALLING = “yes”.
See please my Upgrade and SqlDatabase Component fragments.
My question is, how could I get key value for first part of Condition?
<Upgrade Id="3338faaa-8c9c-43c3-b5ac-3f737d6590fd">
  <UpgradeVersion Minimum="0.0.0.0" Maximum="1.0.2.10010" IncludeMinimum="yes" IncludeMaximum="no" Property="UPGRADEFOUND" />
  <UpgradeVersion Minimum="1.0.2.10010" IncludeMinimum="no" Property="NEWPRODUCTFOUND" />
</Upgrade>

<Component Id="SqlDatabase1" Guid="3338faaa-8c9c-43c3-b5ac-3f73970b42ec" KeyPath="yes">
        <SqlDatabase Id="DATABASE_UNIQUED_IDENTIFIER" Database="[DATABASENAME]" Server="[SERVERADDRESS]" CreateOnInstall="yes" Instance="[SERVERINSTANCE]" User="SQLUser" xmlns="http://schemas.microsoft.com/wix/SqlExtension">
          <SqlString Id="SqlString" SQL=" SQL SCRIPT " ExecuteOnInstall="yes" />

          <SqlScript Id="GenerateDatabase" BinaryKey="GenerateDatabase" ExecuteOnInstall="yes" />
        </SqlDatabase>

        <Condition>NEWPRODUCTFOUND="yes" AND UPGRADEFOUND="no"</Condition>
      </Component>

New Post: Conditionally creating SqlDatabase only by initial Installation, not by Major Upgrade

$
0
0
I don’t know how to get which Condition should be on first position:
:) This is what I meant "you will need to find the real condition". It not trivial. MSI as a technology is extremely convoluted and sometimes determining the state of the product and the status of the session is hard to determine. I have already done this task in the MsiRuntime.cs on GitHub. BTW Wix# project has migrated to GitHub and probably it makes sense to continue this discussion there.

Anyway in the top area of MsiRuntime.cs you will find the table that maps the properties and their values to the install scenarios. You can use this table to compose the required condition. Alternatively you can use Managed Setup events and benefit from the runtime analysis that Wix# already does if this project type is used. Then you can just set your single custom property and it will be later evaluated for your DB installation.
var project = new ManagedProject(...
project.BeforeInstall += project_BeforeInstall;
...
staticvoid project_BeforeInstall(SetupEventArgs e)
{
    bool installed = e.Session["INSTALL_DB"] != ""; 
    bool reinstall = e.Session["REINSTALL"] != ""; 
    bool upgradingProductCode = e.Session["UPGRADINGPRODUCTCODE"] != "";

    if (reinstall && !reinstall && upgradingProductCode)
        e.Session["INSTALL_DB"] = "no";
    else
        e.Session["INSTALL_DB"] = "yes";
Though I cannot truly recommend this approach as I found that it is based on the property values that are not set/behaving at runtime as it is described in MSI documentation. Basically runtime state is not 100% deterministic.

I suggest you just play with ManageSetup/SetupEvents sample (it shows at runtime all relevant properties) and see what are the unique property values combination that correspond to "upgrading" scenario. Then you can use this combination in your code.

New Post: Conditionally creating SqlDatabase only by initial Installation, not by Major Upgrade

New Post: Change id of binary generated by using ElevatedManagedAction

$
0
0
Thanks Oleg,

I am adding the elevatedmanagedaction in an MSM. When trying to build the MSM, the "Id" of the Binary Node is too long due to WIX adding the GUID of the MSM to the end of the "Id". The "Id" I use will have to have at the most 18 characters.

New Post: Multiple instances of managed project

$
0
0
We have a requirement to allow multiple instances of our program. I followed one of the samples and got everything working when instances are invoked from command line. To provide our users with a better experience we want to add a dialog to our project to allow the user to either modify/remove a selected instance or to install a new instance.
So far new instances and updates work perfectly but I’m struggling with the modify. In a previous wix project I got this working by scheduling the dialog before appsearch. But as we are using a managed project the dialogs are embedded and I’m not sure how to schedule a dialog before Appsearch with this approach. So for now I added the dialog in both the modify and the install dialogs, but I need a way to tell the project to use the modify dialogs if the user chooses not to install a new instance.
I also tried launching the dialog in the UIInitialized event, but think If I want to go this route I need to have a different type of UI (not managed).
Can you please advise what the best way is to set instances after launching?
I’ve attached snippets of code, maybe there is something small we are missing.
//managed UI dialogs and sequence
//InstanceSelect is the dialog where the user will choose either a newinstall or a modify
project.ManagedUI = new ManagedUI();      
project.ManagedUI.InstallDialogs.Add<WelcomeDialog>()
                                .Add<InstanceSelect>()                                      
                                .Add<LicenceDialog>()
                                .Add<SetupTypeDialog>()
                                .Add<FeaturesDialog>()
                                .Add<InstallDirDialog>()
                                //.Add<ConfigurationDialog>()
                                .Add<ProgressDialog>()
                                .Add<ExitDialog>();

project.ManagedUI.ModifyDialogs.Add<WelcomeDialog>()
                               .Add<InstanceSelect>()
                               .Add<MaintenanceTypeDialog>()
                               .Add<FeaturesDialog>()
                               .Add<ProgressDialog>()
                               .Add<ExitDialog>();
project.AlwaysScheduleInitRuntime = false;                                

//setup instance transforms for 5 instances
Compiler.WixSourceGenerated += document =>
{
  var instanceTransforms = new XElement("InstanceTransforms", new XAttribute("Property", "INSTANCEID"));
  var guids = new string[] {"B2086842-992F-49AE-AB4A-837C2A21B627", "B3086842-992F-49AE-AB4A-837C2A21B627",
                            "B4086842-992F-49AE-AB4A-837C2A21B627", "B5086842-992F-49AE-AB4A-837C2A21B627",
                            "B6086842-992F-49AE-AB4A-837C2A21B627"};
  var upguids = new string[] {"B2086842-992F-49AE-AB4A-837C2A21B627", "C3086842-992F-49AE-AB4A-837C2A21B627",
                              "D4086842-992F-49AE-AB4A-837C2A21B627", "E5086842-992F-49AE-AB4A-837C2A21B627",
                              "F6086842-992F-49AE-AB4A-837C2A21B627"};
  for (var instance = 1; instance <= 5; instance++)
    instanceTransforms.Add(
      new XElement("Instance",
      new XAttribute("Id", "Instance" + instance),
      new XAttribute("ProductCode", guids[instance - 1]),
      new XAttribute("ProductName", "Our product " + instance),
      new XAttribute("UpgradeCode", upguids[instance - 1])));
  document.Root.Select("Product").Add(instanceTransforms);

};

//upgrades
project.MajorUpgrade = new MajorUpgrade
{
  AllowSameVersionUpgrades = true, //uncomment this if the the upgrade version is different by only the fourth field
  Schedule = UpgradeSchedule.afterInstallInitialize,
  DowngradeErrorMessage = "A later version of [ProductName] is already installed. Setup will now exit."
};
InstanceSelect dialog snippets:
void dialog_Load(object sender, EventArgs e)
    {
      banner.Image = MsiRuntime.Session.GetEmbeddedBitmap("WixUI_Bmp_Banner");
      Text = "[ProductName] Setup";

      //resolve all Control.Text cases with embedded MSI properties (e.g. 'ProductName') and *.wxl file entries
      base.Localize();

      //load installed instances to select from
      instances = new List<RegistryInstance>();
      RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"software\compname\instance");
      if (rk == null)
        rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\compname\instance");
      //look for registry entry and set next available instance
      if (rk != null)
      {
        for(int i = 1; i<=5; i++)
        {
          if (rk.GetValue("Instance" + i) != null && rk.GetValue("Instance" + i).ToString() != "0")
          {
            instances.Add(new RegistryInstance("Instance" + i, rk.GetValue("Instance" + i).ToString()));
            checkedListBox1.Items.Add(instances[i - 1].sDirectory);            
          }
        }        
      }
      //if (instances.Count <= 0)
      //  btnNew.PerformClick();
      
    }

    void cancel_Click(object sender, EventArgs e)
    {
      Shell.Cancel();
    }

    private void btnNew_Click(object sender, EventArgs e)
    {
      int nInstance = 1;
      if (instances.Count > 0)
        nInstance = instances.Count + 1;
      MsiRuntime.Session["INSTANCEID"] = "Instance"+ nInstance;
      MsiRuntime.Session["TRANSFORMS"] = ":" + MsiRuntime.Session["INSTANCEID"] + ";";
      //set default install directory with name of instance id
      MsiRuntime.Session["INSTALLDIR"] = @"C:\Me " + MsiRuntime.Session["INSTANCEID"];
      MsiRuntime.Session["MSINEWINSTANCE"] = "1";
      Shell.GoNext();      
    }

    private void btnModify_Click(object sender, EventArgs e)
    {
      int nInstance = 1;
      if (checkedListBox1.SelectedIndices.Count > 0)
      {
        nInstance = checkedListBox1.SelectedIndices[0] + 1;
        MessageBox.Show("checked instance" + nInstance);
        MsiRuntime.Session["INSTANCEID"] = "Instance" + nInstance;
        MsiRuntime.Session["TRANSFORMS"] = ":" + MsiRuntime.Session["INSTANCEID"] + ";";
        //set default install directory with name of instance id
        MsiRuntime.Session["INSTALLDIR"] = @"C:\Me " + MsiRuntime.Session["INSTANCEID"];
        MsiRuntime.Session["MSINEWINSTANCE"] = "1";
        //added the following section to try and force the maintenace sequence but
        //when trying to remove installed product I get:
        //DEBUG: Error 2755:  Server returned unexpected error 1639 attempting to install package
        Shell.Dialogs.Clear();
        Shell.Dialogs.Add<WelcomeDialog>();
        Shell.Dialogs.Add<InstanceSelect>();
        Shell.Dialogs.Add<MaintenanceTypeDialog>();
        Shell.Dialogs.Add<FeaturesDialog>();
        Shell.Dialogs.Add<ProgressDialog>();
        Shell.Dialogs.Add<ExitDialog>();
        Shell.GoNext();
      } 
    }
  }

New Post: Total MSI File size exceeding 2GB

$
0
0
Hi,

My total file size within an Wix# project including data exceeds 2GB and currently I am unable to create Setup. Read in Wix documentation that multiple cab will solve the issue. How can I do that in Wx#

New Post: Total MSI File size exceeding 2GB

$
0
0
You can add as many Media elements as you need with XML post-processing:
project.WixSourceGenerated += Compiler_WixSourceGenerated;
...
staticvoid Compiler_WixSourceGenerated(XDocument document)
{
    document.Root
            .Select("Product")
            .AddElement("Media", "Id=1; Cabinet=MyProduct1.cab; EmbedCab=no")
            .AddElement("Media", "Id=2; Cabinet=MyProduct2.cab; EmbedCab=no")
            .AddElement("Media", "Id=3; Cabinet=MyProduct3.cab; EmbedCab=no");
...
And when you add a file you can always pass the desired media id:
new File(@"Files\Bin\MyApp.exe") { AttributesDefinition = "DiskId=2" }
But I cannot say I like this solution. The MediaTemplate element is much more elegant approach as it (with a single element) defines the splitting algorithm without explicit mapping cabs and files.

Approach is the same:
document.Root.Select("Product/Media").Remove(); //don't need it any more
document.Root.Select("Product")
             .AddElement("MediaTemplate", "MaximumCabinetSizeForLargeFileSplitting=2048");
You can even drop the MaximumCabinetSizeForLargeFileSplitting=2048 as it is a default value anyway.


I think it is a good feature to go to default features set. Please log the feature request on GitHub and I will implement it as something like this:
project.MediaTemplate = new MediaTemplate{MaximumCabinetSizeForLargeFileSplitting=2048};
//or
project.Cabs = MediaTemplate.Default; 
Please use GitHub for any further discussions: https://github.com/oleg-shilo/wixsharp

New Post: Multiple instances of managed project

$
0
0
"UIInitialized event" is what I wanted to suggest. And you need ManagedProject for this. Exactly what you are already using. So you are good.

I cannot see anything obviously wrong with your code by just reading it. I apologize but I just do not have time for building and running the test case from it. So my assessment is a bit superficial.

If you need any further help/discussion you can also try the GitHub the current home for Wix#.

New Post: Multiple instances of managed project

$
0
0
Thank you for the reply even though you are busy.

Could you maybe explain how I would launch an embedded dialog in the UInitialized event? I tried showdialog, but it complains about the msiruntime and msi properties.

Or is there anyway to reset the setup type that will in effect load another set of dialogs. In other words go from Install dialogs to modify dialogs?
Viewing all 1354 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>