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

New Post: later to define install dir

$
0
0
It's hard for me to comment on your code as the only thing that I know about it is that "it doesn't work".

The following is a complete code that does work. You probably will be able to adjust it to your requirements:
//css_dir ..\..\..\;//css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll;//css_ref WixSharp.UI.dll;//css_ref System.Core.dll;//css_ref System.Xml.dll;using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using WixSharp;
using WixSharp.Forms;
using WixSharp.UI.Forms;

publicclass Script
{
    staticpublicvoid Main()
    {
        var project =
            new ManagedProject("ManagedSetup",
                new Dir(@"%ProgramFiles%\My Company\My Product",
                    new File(@"..\Files\bin\MyApp.exe"),
                    new Dir("Docs",
                        new File("readme.txt"))));

        project.ManagedUI = ManagedUI.Empty;
        project.Load += project_Load;
        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");

        Compiler.BuildMsi(project);
    }

    staticvoid project_Load(SetupEventArgs e)
    {
        try
        {
            if (string.IsNullOrEmpty(e.Session["INSTALLDIR"])) //installdir is not set yet
            {
                string installDirProperty = e.Session.Property("WixSharp_UI_INSTALLDIR");
                string defaultinstallDir = e.Session.GetDirectoryPath(installDirProperty);

                e.Session["INSTALLDIR"]= System.IO.Path.Combine(defaultinstallDir, Environment.UserName);
            }
        }
        catch { }
        MessageBox.Show(e.ToString(), "Load");
    }
}

New Post: Installer requires .net 3.5 features to be installed

$
0
0
OK. Then .NET is OK. Great.

Then I assume the only problem you have is that the UI somehow doesn;t work properly on the tarhget system. Is this correct? If it is please simplify your code down to the level of HelloWorld project and post it her or to me directly. I will have a look at it.

New Post: Installer requires .net 3.5 features to be installed

New Post: Installing vcredist_x86.exe or vcredist_x64.exe

$
0
0
I have a WPF external UI. What is the best way to install the C++ runtime libs? My preference is to silently run the executable version of the installer. An example would be much appreciated.

Thanks in advance.

New Post: Installing vcredist_x86.exe or vcredist_x64.exe

$
0
0
First you will need to embed your vcredist_x*.exe with Binary. After that you need to setup managed custom action and call Process.Start(...) from it.

Have a look at <Wix#>\Samples\Bootstrapper\Simplified Bootstrapper. It actually implements exactly your scenario.

New Post: later to define install dir

$
0
0
I made something similar:
static void Main()
        {
            var serviceName = "Pdf";
 
            var pdfIisSite = new WebSite(serviceName)
            {
                InstallWebSite = false,
                Description = "[IISWEBSITE_NAME]",
                AttributesDefinition = "Directory=INSTALLDIR; SiteId=*"
                Addresses = new[]
                {
                    new WebSite.WebAddress
                    {
                        Attributes = new Attributes()
                        {
                            {"Port", "8080"},
                        }
                    }
                }
            };
 
            var project = new ManagedProject("MyProductName",
                new Dir(@"%ProgramFiles%\MyCompany\MyProduct\Pdf",
                    new Files(@"_PublishedWebsites\WebProject\*.*"),
                    new File(System.IO.Path.GetFullPath("License.rtf"),
 
                        new IISVirtualDir()
                        {
                            AppName = "[PDFSERVICE_NAME]",
                            Name = "VirtualDirForScPdf",
                            Alias = "[PDFSERVICE_NAME]",
 
                            WebDirProperties = new WebDirProperties(serviceName)
                            {
                                AttributesDefinition = "AnonymousAccess=yes; WindowsAuthentication=no"
                            },
 
                            WebSite = pdfIisSite,
 
 
                            WebAppPool = new WebAppPool("[PDFWEB_APPPOOL]")
                            {
                                Attributes = new Attributes()
                                {
                                    {"ManagedRuntimeVersion", "v4.0"},
                                    {"ManagedPipelineMode", "Integrated"}
                                }
                            }
                        })),
                        new Property("IISWEBSITE_NAME", "SomeName"),
                        new Property("PDFSERVICE_NAME", "Pdf"),
                        new Property("PDFWEB_APPPOOL", "Pdfcustom"),
                        new Property("PDFAUTHENTICATION", "empty"),
                        new SetPropertyAction("MSIUSEREALADMINDETECTION", "1")
                        );
 
            project.GUID = new Guid("be4f117e-cfba-40ad-a345-fbf4daa531d4");
 
            
            
            //custom set of standard UI dialogs
            project.ManagedUI = new ManagedUI();
 
            project.ManagedUI.InstallDialogs.Add(Dialogs.Welcome)
                                            .Add(Dialogs.Licence)
                                            .Add<CustomDialog>()
                                            .Add(Dialogs.Progress)
                                            .Add(Dialogs.Exit);
 
            project.ManagedUI.ModifyDialogs.Add(Dialogs.MaintenanceType)
                                           .Add(Dialogs.Features)
                                           .Add(Dialogs.Progress)
                                           .Add(Dialogs.Exit);
 
            project.Load += Msi_Load;
            project.BeforeInstall += Msi_BeforeInstall;
            project.AfterInstall += Msi_AfterInstall;
 
            
            ValidateAssemblyCompatibility();
 
            project.BuildMsi();
        }


static void Msi_Load(SetupEventArgs e)
        {
 
            var selectedSite = e.Session["IISWEBSITE_NAME"];
            var serviceName = e.Session["PDFSERVICE_NAME"];
 
            var iisManager = new ServerManager();
            var sites = iisManager.Sites;
            var site = sites.SingleOrDefault(s => s.Name == selectedSite);
            if (site != null)
                e.Session["INSTALLDIR"] =
                    Path.Combine(site.Applications[0].VirtualDirectories[0].PhysicalPath, serviceName);
 
            MessageBox.Show("install dir set to : " + e.Session["INSTALLDIR"]);
            
            
            if (!e.IsUninstalling)
                MessageBox.Show(e.ToString(), "Load");
        }
But installation fails with 2 errors:

Error: Could not access network location %SystemDrive%\inetpub\wwwroot\pdf.
Error: Could not access network location %SystemDrive%\inetpub\wwwroot\pdf.

I also ran msi installer from cmd which run under Administrator.

New Post: later to define install dir

$
0
0
Unfortunately your code is incomplete so I cannot compile it.

Anyway, just after inspecting your code I can say that I don't see anything obviously wrong with it. At least from Wix# point of view. However the error details you provided indicate that there is somewhere a routine that uses %SystemDrive% expandable environment variable. It is not user (your) code. At least not that part that you shared. It's not Wix# as it never uses this variable. So it might be WiX or that missing part of your code.

The easiest way to investigate it is to inspect the *.wxs file and see if %SystemDrive% was in fact injected there. This file is automatically be placed in the wix folder of your project. Though if you are not using Visual Studio to compile msi then you will need to prevent clearing this temporary file with project.PreserveTempFiles = true;.

New Post: Installing vcredist_x86.exe or vcredist_x64.exe

$
0
0
Your suggested approach never fired the custom action because I'm using the WPF external UI approach. This turned out to be more involved.

Below are the relevant code snippets. On Windows 7, I'm getting this error from the process that is launched to install the CRT: ERROR_INSTALL_ALREADY_RUNNING

I'm not convinced my use of Sequence.InstallExecuteSequence and Step.CostFinalize is correct. I want the CRT to be installed before everything else but execute as part of the installation process. Because it's an external UI implementation, how do you prevent two instances of the installer running simultaneously as is reported under Windows 7? I guess this is due to the fact that the MSI is running when the secondary install process is launched?

Curiously, everything works as expected on Windows 8/10 (very strange). Any ideas?

// ...
    Project project = new Project(PRODUCT_NAME,
        rootDir,
        new Binary(new Id("vcredist2012"), extrasDirectory.FullName + @"\x86\2012vcredist_x86.exe"),
        new Binary(new Id("vcredist2013"), extrasDirectory.FullName + @"\x86\2013vcredist_x86.exe"),
        new ManagedAction(@"Install2012CRTAction", Return.check, When.Before, Step.CostFinalize, Condition.NOT_Installed, Sequence.InstallExecuteSequence),
        new ManagedAction(@"Install2013CRTAction", Return.check, When.Before, Step.CostFinalize, Condition.NOT_Installed, Sequence.InstallExecuteSequence),
        //new ManagedAction(@"InstallCRTAction", Return.check, When.Before, Step.InstallExecute, Condition.NOT_Installed, Sequence.InstallExecuteSequence),
        new LaunchCondition("CUSTOM_UI=\"true\" OR REMOVE=\"ALL\"", "Please run " + PRODUCT_NAME + ".Installer.exe instead."))
// ...
[CustomAction]
public static ActionResult Install2012CRTAction(Session session)
{
    session.Log(string.Format("----- Custom Action CRT 2012 -----\r\n"));
    return InstallCRT(session, "vcredist2012");
}

[CustomAction]
public static ActionResult Install2013CRTAction(Session session)
{
    session.Log(string.Format("----- Custom Action CRT 2013 -----\r\n"));
    return InstallCRT(session, "vcredist2013");
}

static ActionResult InstallCRT(Session session, string crtName)
{
    string CRTExeId;
    bool hasCRT = false;

    CRTExeId = crtName.Expand();

    if (crtName.EndsWith("2012"))
        hasCRT = IsVS2012CRTInstalled();
    else if (crtName.EndsWith("2013"))
        hasCRT = IsVS2013CRTInstalled();

    if (!hasCRT)
    {
        string CRTExeFile = io.Path.ChangeExtension(io.Path.GetTempFileName(), ".exe");
        session.SaveBinary(CRTExeId, CRTExeFile);

        ProcessStartInfo info = new ProcessStartInfo();
        info.FileName = CRTExeFile;
        info.Arguments = string.Format("/install /quiet /norestart /log %TEMP%\\{0}.log", crtName);

        session.Log(string.Format("Custom Action Launch: {0} {1}\r\n", info.FileName, info.Arguments));

        // Launch CRT installer.
        Process process = Process.Start(info);
        process.WaitForExit();

        if (process.ExitCode == -2147023278) // Check if ERROR_INSTALL_ALREADY_RUNNING == -2147023278
            session.Log("Custom Action Error Code: ERROR_INSTALL_ALREADY_RUNNING\r\n");

        session.Log(string.Format("Custom Action Exit Code: {0}\r\n", process.ExitCode));

        if (crtName.EndsWith("2012"))
            hasCRT = IsVS2012CRTInstalled();
        else if (crtName.EndsWith("2013"))
            hasCRT = IsVS2013CRTInstalled();

        if (!hasCRT) // CRT installation might fail.
            return ActionResult.Failure;
    }

    return ActionResult.Success;
}

static bool IsVS2012CRTInstalled()
{
    using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\DevDiv\vc\Servicing\11.0\RuntimeMinimum"))
    {
        if (key != null)
        {
            var dw = key.GetValue("Install");
            return dw.ToString() == "1";
        } else
            return false;
    }
}

static bool IsVS2013CRTInstalled()
{
    using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\DevDiv\vc\Servicing\12.0\RuntimeMinimum"))
    {
        if (key != null)
        {
            var dw = key.GetValue("Install");
            return dw.ToString() == "1";
        } else
            return false;
    }
}
// ...

New Post: Installing vcredist_x86.exe or vcredist_x64.exe

$
0
0
MSI installations are atomic. You cannot have two installations active at the time. It is the model enforced by MSI runtime.

You cannot have two installations running at the same time in the active installation phase. However you can have two installations running at the same time in the collecting user input (UI) phase. The active installation phase starts when you press that "install" button on UI.

This is why I directed you towards the sample. It triggers the secondary installation before its own while it's interacting with the user. It does it at that 'pre-install' stage. As you correctly noted, because you are using an external UI this stage is 'taken over' by your UI and it is the reason why the custom action is not fired. Thus you need to duplicate the custom action routine in your UI so it can be executed in both cases "setup with UI" and "silent setup".

However it seems to me that the whole approach becoming is less suitable after your extra (stronger) requirement: "I want the CRT to be installed before everything else but executeas part of the installation process.". You may benefit from the bootstrapper. Have a look at the included samples. I think you will be mostly interested in the WixBootsrtapper_NoUI sample, which installs prerequisite while relying on the primary MSI setup UI. There is also a sample of the WPF boostrapper UI (WixBootsrtapper_UI)

New Post: Q: Uninstall results in Registry Key removal (not just Registry Key property)

$
0
0
I wan't my installer to add the Registry Key property, but not remove it (or the Registry Key!) during an uninstall. How can I avoid this? (I'm using VS 2013 to build this).

Code is a VERY simple installer
---snip---
Project project = new Project("Personal Office Document Templates",
            new RegFile(@"Office personal template location.reg")
        );

        project.GUID = new Guid("<REMOVED>"); 
        Compiler.BuildMsi(project);
---snip---

Registry file is as follows
---snip---
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Word\Options]
"PersonalTemplates"="C:\Program Files (x86)\UNIFY Solutions\Office Document Templates"

[HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\PowerPoint\Options]
"PersonalTemplates"="C:\Program Files (x86)\UNIFY Solutions\Office Document Templates"

---snip---

Help!

New Post: Q: Uninstall results in Registry Key removal (not just Registry Key property)

$
0
0
WiX requires use of the 'Permanent' component attribute for that. You can controll it either per Reg value or for all of them in a single step as follows:
project.RegValues.ForEach(r => { r.AttributesDefinition = "Component:Permanent=yes"; });

New Post: Q: Uninstall results in Registry Key removal (not just Registry Key property)

$
0
0
Marvelous, thank you!

Sincerely,
//Adam

New Post: How to change the Publisher value displayed in the control panel

$
0
0
How to change the Publisher value displayed in the control panel ?
What is the api?
It is always assign as the publisher the username of the process that compiled the project

Thanks

New Post: UnInstall Cleanup

$
0
0
Hi Oleg;

Good work!
Using WixSharp to build our package

Looking to completely uninstall apps but MSI does leave a logs directory behind as created by the App at runtime;

How can I remove this at Uninstall time?

Thanks in advance
David Tuke

New Post: How to change the Publisher value displayed in the control panel

$
0
0
Have a look at <Wix#>\Samples\ProductInfo\setup.cs sample

New Post: Installing Files to Public Documents Folder

$
0
0
What is the proper way to install to the CommonDocuments location? i.e. C:\Users\Public\Documents

There doesn't seem to be any environment/sessions variables available for this location.

New Post: Installing Files to Public Documents Folder

$
0
0
Correct, there is none.

It is not a typical deployment story to install something into this folder. It is designed to be populated with the files created by users or applications but not by the setup application. That is why MSI (not Wix#) doesn't define the name/variable (like 'DesktopFolder') for this folder. See the full reference here:
AdminToolsFolder
AppDataFolder
CommonAppDataFolder
CommonFiles64Folder
CommonFilesFolder
DesktopFolder
FavoritesFolder
FontsFolder
LocalAppDataFolder
MyPicturesFolder
PersonalFolder
ProgramFiles64Folder
ProgramFilesFolder
ProgramMenuFolder
SendToFolder
StartMenuFolder
StartupFolder
System16Folder
System64Folder
SystemFolder
TempFolder
TemplateFolder
WindowsFolder
WindowsVolume
AdminToolsFolder
AppDataFolder
CommonAppDataFolder
CommonFiles64Folder
CommonFilesFolder
DesktopFolder
FavoritesFolder
FontsFolder
LocalAppDataFolder
MyPicturesFolder
PersonalFolder
ProgramFiles64Folder
ProgramFilesFolder
ProgramMenuFolder
SendToFolder
StartMenuFolder
StartupFolder
System16Folder
System64Folder
SystemFolder
TempFolder
TemplateFolder
WindowsFolder
Though you can always place anything you want in this folder from the custom action:
var project =
    new ManagedProject(...

project.BeforeInstall += Project_BeforeInstall;
...
 

staticvoid Project_BeforeInstall(SetupEventArgs e)
{
    string file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "mydoc.txt");
    if (e.IsInstalling)
    {
        e.Session.SaveBinary("<embedded file ID>", file);
    }
}

New Post: UnInstall Cleanup

$
0
0
Hi David,

Thank you. I am glad you like Wix#.

>...MSI does leave a logs directory behind...
This is how MSI works. If you place any file (e.g. log) in the installed app folder this folder will not be deleted during uninstall. The idea behind this is that you are not expected to write anything into these folders. Thus %ProgramFiles% is a "holly cow" and no one, even the installed app, should be writing there. All logs, settings etc. supposed to go to the user profile.

Though if you really need to use a brut force for deleting the folders the you can do this similar to the code below:
var project =
    new ManagedProject(
...
project.AfterInstall += Project_AfterInstall;
...
staticvoid Project_AfterInstall(SetupEventArgs e)
{
    if (e.IsUninstalling)
    {
        string logDir = IO.Path.Combine(e.InstallDir, "Logs");
        IO.Directory.Delete(logDir, recursive: true);
    }
}

New Post: Installing Files to Public Documents Folder

$
0
0
Thank you, Oleg. BTW- I'm loving Wix#. Very well done!

New Post: Installing Files to Public Documents Folder

Viewing all 1354 articles
Browse latest View live


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