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

New Post: How to get textbox values from Custom CLR dialog and use inside CustomAction

$
0
0
I went through "Setup Events"
static void project_Load(SetupEventArgs e)
    {
        var msi = e.MsiFile;

        SetEnvVersion(e.Session);

        //MSI doesn't preserve any e.Session properties if they are accessed from deferred actions (e.g. project_AfterInstall)
        //Wix# forces some of the properties to be persisted (via CustomActionData) by using user defined 
        //project.DefaultDeferredProperties ("INSTALLDIR,UILevel" by default).
        //Alternatively you can save any data to the Wix# specific fully persisted data properties "bag" SetupEventArgs.Data.
        //SetupEventArgs.Data values can be set and accesses at any time from any custom action including deferred one.  
        var conn = @"Data Source=.\SQLEXPRESS;Initial Catalog=RequestManagement;Integrated Security=SSPI";
        __e.Data["persisted_data"]__ = conn; 

        MessageBox.Show(e.ToString(), "Load " + e.Session["EnvVersion"]);
    }
static void project_AfterInstall(SetupEventArgs e)
    {
        MessageBox.Show(e.ToString() +
                        "\npersisted_data = " + __e.Data["persisted_data"]__ +
                        "\nADDLOCAL = " + e.Session.Property("ADDLOCAL"),
                        caption: "AfterExecute ");

        try
        {
            System.IO.File.WriteAllText(@"C:\Program Files (x86)\My Company\My Product\Docs\readme.txt", "test");
        }
        catch { }
    }
Now here conn string is hardcoded, i am still not getting how to set it from my custom CLR dialog it's a win form combobox also at what event it should be set to session?

So basically what my understanding is.
private void Next_Click(object sender, EventArgs e)
        {
            //session["AppVersion"] = comboBox1.Text;  // value needs to be set here 'somehow'
            MSINext();
        }

New Post: Force ScheduleReboot

$
0
0
Sorry, I completely puzzled by this. In my simple test (slightly modified InstallFiles) it did pop the prompt.
I can only assume that the reboot is indeed is scheduled but the UI prompt is suppressed because of the EmbeddedUI. It is actually plausible as MSI completely delegates the UI sequence to the user defined routine - ManagedUI.

If it is the case then what you need to do is to pop up your own UI prompt (some simple WinForm based dialog) from ExitDialog or better yet from AfterInstall event.

New Post: More then one Projekt as InstallerFiles

$
0
0
This will not work. There are quite a few wrong things with your code:
  • As any LINQ extension method Distinct does not modify the collection. You need to reassign it.
  • Also your Distinct will not work anyway as DirFileCollections is a list wild card patterns not the resolved files.
  • Wix# doesn't have DirFiles constructor that you specified.
You need to use lambdas in the constructor with wildcard:
var sharedDLLs = new [] { "shared1.dll",  "shared2.dll" }; 

var ProgrammDir = new Dir($"%ProgrammFiles%/{Manufacturer}/{Produkt}",
                               new File (MainExe,
                               new FileShortcut("","")),
                               new DirFiles(@"outDir1\.*.dll",  x => ! sharedDLLs.Contains(Path.GetFileName(x))),
                               new DirFiles(@"outDir2\.*.dll", x => ! sharedDLLs.Contains(Path.GetFileName(x)))
                        );
...
project.ResolveWildCards();
var dir = project.FindDir("whatever");
dir.Files = dir.Files.Add(new File("whatever_dll"));
This is how you filter duplicates and add files explicitly but I am not sure it is what you need. It didn't look like the most elegant solution. May be something like this is a bit better:
var alreadyAdded = new List<string>(); 

Func<string, bool> ifNew = (file)=>
{
    if(alreadyAdded.Contains(file))
        returnfalse;
    alreadyAdded.Add(file);
    returntrue;
};

var ProgrammDir = new Dir($"%ProgrammFiles%/{Manufacturer}/{Produkt}",
                               new File (MainExe,
                               new FileShortcut("","")),
                               new DirFiles(@"outDir1\.*.dll",  ifNew),
                               new DirFiles(@"outDir2\.*.dll", ifNew)
                        );

New Post: How to get textbox values from Custom CLR dialog and use inside CustomAction

$
0
0
EmbeddedUI/ManagedUI
Have a look at CustomUIDialog sample. Itr shows how to set session properties aor tunneled for deferred action Data:
void next_Click(object sender, EventArgs e)
        {
            MsiRuntime.Session["PASSWORD"] = password.Text;
            MsiRuntime.Session["DOMAIN"] = domain.Text;
            MsiRuntime.Data["test"] = "test value";
            Shell.GoNext();
        }
CLR Dialog
Have a look at CustomCLRDialog. It will be something like this:
privatevoid nextBtn_Click(object sender, EventArgs e)
{
    this.session["prop name"] = "whatever";
    MSINext();
} 

New Post: More then one Projekt as InstallerFiles

New Post: More then one Projekt as InstallerFiles

$
0
0
Then change it to match the signature exactly:
new DirFiles(@"outDir1\.*.dll",  x=>ifNew(x))
//or
Predicate<string> ifNew = (file)=>

New Post: Force ScheduleReboot

$
0
0
It appears to work fine (displays the "do you want to restart now or later" dialog) until I add the below code...
        project.ManagedUI = new ManagedUI();
        project.ManagedUI.InstallDialogs.Add(Dialogs.Welcome)
                                        .Add(Dialogs.Licence)
                                        .Add(Dialogs.SetupType)
                                        .Add(Dialogs.Features)
                                        .Add(Dialogs.InstallDir)
                                        .Add(Dialogs.Progress)
                                        .Add(Dialogs.Exit);
or...
        project.ManagedUI = ManagedUI.Default;
Looks like once the ManagedUI sequence modifies it to no longer show the prompt.


Thanks for the help. I'll have to take your recommendation to build my own "do you want to reboot" dialog.

New Post: How to get textbox values from Custom CLR dialog and use inside CustomAction

$
0
0
let me rephrase my question.
i am doing

project.DefaultDeferredProperties += ";AppVersion";

then
private void Next_Click(object sender, EventArgs e)
        {
            session["AppVersion"] = comboBox1.Text; 
            MSINext();
        }
now when i do
private static void Project_AfterInstall(SetupEventArgs e)
        {
             var appVersion = e.Data["AppVersion"];
             //or
             //var appVersion = e.Session.Property("AppVersion");
            //or
           //var appVersion = e.Session["AppVersion"]
        }
none of them fetching data from CLR dialog.
So what i am missing here,I went to custom_ui , deferred actions and setup events sample but still not getting how data is passed from CLR dialog to after_install.

Btw thanks a lot for helping me out.

New Post: How to get textbox values from Custom CLR dialog and use inside CustomAction

$
0
0
finally made it work i found CustomUIDialog inside managed setup sample.
and change my project to managed one as it seems more controllable on UI.

But it was not working until i changed "AppVersion" to "APPVERSION"
I think my naming convention was not supported by wix?

New Post: How to get textbox values from Custom CLR dialog and use inside CustomAction

$
0
0
> I think my naming convention was not supported by wix?
It is actually MSI (not WiX) design perl. :)
If the property is to be used outside it needs to be declared as public. Makes sense, doesn't it? But the the way you do is is not something one would expect... You need to declare it in all capital.

>But it was not working until i changed "AppVersion" to "APPVERSION"
Strangely enough I have checked the SetupEvents sample and in my test I was able to tunnel lower-case property to the AfterInstall. Thus may be in your test it was because of mismatch of the property name in project.DefaultDeferredProperties and e.Session.Property(....

Anyway, your code snippet shows that there are a few points you need to do differently when you access your properties.

The last line will throw the exception because AfterInstall is a deferred action and the session object is already disconnected. Thus you need to access the property with e.Session.Property("AppVersion").

The e.Data["AppVersion"] statement should be used only if you set data from the dialog with this.MsiRuntime.Data["AppVersion"] = "some value"; and I am not sure you did.

And another point to remember. If you use MsiRuntime.Data then you don't need to do project.DefaultDeferredProperties as the whole MsiRuntime.Data dictionary is tunneled to the AfterInstall event handler. Meaning that there is a less chance that something will go wrong.

> change my project to managed one as it seems more controllable on UI.
100% agree.

New Post: How to get textbox values from Custom CLR dialog and use inside CustomAction

$
0
0
And another point to remember. If you use MsiRuntime.Data then you don't need to do project.DefaultDeferredProperties as the whole MsiRuntime.Data dictionary is tunneled to the AfterInstall event handler. Meaning that there is a less chance that something will go wrong.
Ok got it so previously i was using MsiRuntime.session[] and reading it with e.session.property() thus i was using new propery("APPVERSION"){isdeffered = true}
now change it to MsiRuntime.Data[].
thanks

New Post: Issue getting WixSharp working.

$
0
0
I am getting various Wix# errors even with the simplest example. About this method of setting the value of WixLocation..

I placed the files from WixSharp.1.0.44.0.7z on my box thusly:

C:\Program Files (x86)\WixSharp.1.0.44.0\ <- This contains cscs.exe, WixSharp.dll and other files as originally arranged in your download
C:\Program Files (x86)\WixSharp.1.0.44.0\Wix_bin <- This contains the bin, and SDK folders
C:\Program Files (x86)\WixSharp.1.0.44.0\Wix_bin\bin <- This contains the x86 folder and a 70 other files

I tried setting environment-var WIXSHARP_WIXDIR to "C:\Program Files (x86)\WixSharp.1.0.44.0\Wix_bin\bin"

And ran cscs.exe against the Setup.cs file, but it gives "ArgumentException: Illegal characters in path.."

I tried adding this line to Main within Setup.cs :
        WixSharp.Compiler.WixLocation = @"C:\Program Files (x86)\WixSharp.1.0.44.0\Wix_bin\bin";
But now I get: Error: Specified file could not be executed.
FileNotFoundException: .. assembly 'Microsoft.Deployment.WindowsInstaller, Version=3.0.0.0..
(although this file does exist in that Wix_bin\bin folder)

What is wrong? I am not able to get anything to build at all !

New Post: "Illegal characters in path" trying to run any sample installer

$
0
0
Hello, thank you for creating and sharing this project.

I downloaded WixSharp.1.0.44.0 today, uncompressed it and am trying to follow your tutorial, but cannot get any of the samples to work. I also tried to use the Visual Studio project template to create a new "WixSharp Setup" project, but I can't get that to work either.

I set the environment-variable WIXSHARP_WIXDIR to C:\Program Files (x86)\WixSharp.1.0.44.0\Wix_bin\bin

When I open a DOS window and go to, for example, your sample program ProductInfo, and enter
Build.cmd

it says..

C# Script execution engine. Version 3.12.2.0
Error: Specified file could not be executed.
System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(string path, Boolean checkAdditional)
..
at Script.Main(String[] args)

What have I done wrong? !!

Thank you for your time and help,
James W. Hurst
JamesH@Designforge.com I am running Windows 10 x64, and using Visual Studio 2015

New Post: "Illegal characters in path" trying to run any sample installer

$
0
0
Typically Wix# compiler is capable of finding WiX installation even without relying on WIXSHARP_WIXDIR variable. Though if this for whatever reason is not happening using VS templates is preferably a better option to start the troubleshooting with.

This is what you can do.
  1. Create a fresh project from "WixSharp Setup" template.
  2. In package management console execute install-package WixSharp
  3. In package management console execute install-package WixSharp.wix.bin
  4. In the code assign Compiler.WixLocation to the location of the WiX bin (either relative or absolute)
//DON'T FORGET to execute "install-package wixsharp" in the package manager console
Compiler.WixLocation = @"..\packages\WixSharp.wix.bin.3.10.1\tools\bin";
Let me know it it worked for you.

New Post: MSI is not created after successful build

$
0
0
Hi ,
I am using WIX # extension (WIXCustomUI) for the project for creating the MSI file.On rebuilding demo project ,MSI file will not be created in bin folder.
Please have a look at the code.

Both the project are in .net framework 4.5.
I added a reference to my main project in this setup project.
Can somebody please provide some getting started document.
static void Main()
    {
        //DON'T FORGET to execute "Install-Package WixSharp" in the Package Manager Console


        var project = new ManagedProject("MyProduct",
                         new Dir(@"%ProgramFiles%\My Company\My Product",
                             new File("Program.cs")));

        project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b");

        //custom set of standard UI dialogs
        project.ManagedUI = new ManagedUI();

        project.ManagedUI.InstallDialogs.Add<WelcomeDialog>()
                                        .Add<LicenceDialog>()
                                        .Add<SetupTypeDialog>()
                                        .Add<FeaturesDialog>()
                                        .Add<InstallDirDialog>()
                                        .Add<ProgressDialog>()
                                        .Add<ExitDialog>();

        project.ManagedUI.ModifyDialogs.Add<MaintenanceTypeDialog>()
                                       .Add<FeaturesDialog>()
                                       .Add<ProgressDialog>()
                                       .Add<ExitDialog>();

        project.UI = WUI.WixUI_InstallDir;

        //project.SourceBaseDir = "<input dir path>";
        //project.OutDir = "<output dir path>";

       // ValidateAssemblyCompatibility();

        project.BuildMsi();
    }

New Post: MSI is not created after successful build

$
0
0
Hi ,
I am using WIX # extension (WIXCustomUI) for the project for creating the MSI file.On rebuilding demo project ,MSI file will not be created in bin folder.
Please have a look at the code.

Both the project are in .net framework 4.5.
I added a reference to my main project in this setup project.
Can somebody please provide some getting started document.
static void Main()
    {
        //DON'T FORGET to execute "Install-Package WixSharp" in the Package Manager Console


        var project = new ManagedProject("MyProduct",
                         new Dir(@"%ProgramFiles%\My Company\My Product",
                             new File("Program.cs")));

        project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b");

        //custom set of standard UI dialogs
        project.ManagedUI = new ManagedUI();

        project.ManagedUI.InstallDialogs.Add<WelcomeDialog>()
                                        .Add<LicenceDialog>()
                                        .Add<SetupTypeDialog>()
                                        .Add<FeaturesDialog>()
                                        .Add<InstallDirDialog>()
                                        .Add<ProgressDialog>()
                                        .Add<ExitDialog>();

        project.ManagedUI.ModifyDialogs.Add<MaintenanceTypeDialog>()
                                       .Add<FeaturesDialog>()
                                       .Add<ProgressDialog>()
                                       .Add<ExitDialog>();

        project.UI = WUI.WixUI_InstallDir;

        //project.SourceBaseDir = "<input dir path>";
        //project.OutDir = "<output dir path>";

       // ValidateAssemblyCompatibility();

        project.BuildMsi();
    }

New Post: MSI is not created after successful build

$
0
0
After the successful build the msi file is created in the project directory.
When you add NuGet package VS displayed readme.txt with the brief instructions on how to set up and build your msi:
After building the project the corresponding .msi file can be found in the root project folder.

Tips and Hints:
If you are implementing managed CA you may want to set "Target Framework" to "v3.5" as the lower CLR version will help avoid potential conflicts during the installation (e.g. target system has .NET v3.5 only).

Note: 
Wix# requires WiX Toolset (tools and binaries) to function properly. Wix# is capable of automatically finding WiX tools only if WiX Toolset installed. In all other cases you need to set the environment variable WIXSHARP_WIXDIR or WixSharp.Compiler.WixLocation to the valid path to the WiX binaries.
...
If you need more details then you can find some on this very website Wiki: https://wixsharp.codeplex.com/documentation

New Post: "Illegal characters in path" trying to run any sample installer

$
0
0
Following your steps exactly, got me past this hurdle. Thank you!

New Post: How to install Start-Menu items in addition to Desktop icon ?

$
0
0
Hi, I am trying to follow the examples to accomplish a simple setup and am hashing about in confusion over something.

I want the installer to insert into the Start Menu, within the folder for My Company, a simple shortcut to run my program. This is addition to installing also a shortcut onto the Desktop (which is working, thanks).

I see your sample "ShortCut" but I don't want an entry for Samples, nor for un-install. Just a simple program-launcher.

Here is what I have at this moment...
           var project = new Project("DesignForge ImageVUr",
                                      new Dir(@"C:\Program Files\DesignForge\ImageVUr",
                                              //new Dir( @"%ProgramFiles%\My Company\My Product",
                                              new Files(@"Files\Bin\*.*", f => !f.EndsWith(".exe")),
                                              new File(@"Files\Docs\Manual.txt"),
                                              new File(@"Files\Bin\ImageVUr.exe",
                                                       new FileShortcut("ImageVUr", "INSTALLDIR"), //INSTALLDIR is the ID of "%ProgramFiles%\My Company\My Product" 
                                                       new FileShortcut("ImageVUr", @"%Desktop%") {IconFile = @"Files\Bin\App.ico", WorkingDirectory = "%Temp%"})),

                                      new Dir(@"%ProgramMenu%\DesignForge",
                                              new ExeFileShortcut("ImageVUr", "INSTALLDIR", "")));

"DesignForge" is the name for My Company, and "ImageURr" is My Program.

It is creating the folder "DesignForge", however it is empty. No program-shortcut within it.

Q: What is the purpose of project.UI = WUI.WixUI_InstallDir; ?

Q: What is the difference between a FileShortcut and a ExeFileShortcut ?


Thank you for your help!

sincerely,

James W. Hurst
e-mail: JamesH@Designforge.com

New Post: How to install Start-Menu items in addition to Desktop icon ?

$
0
0
Hi James,

It's hard for me to comment details of your code. I think you can get all your answers from the Samples\Shortcuts sample. It does exactly what you need.

>FileShortcut and a ExeFileShortcut
They are two different beasts.
FileShortcut is a definition of the shortcut associated with the installed file. Thus it can only have WixSharp.File as a parent. But ExeFileShortcut is a stand alone shortcut to any exe file on the system and it should be a child of WixSharp.Dir.
Unfortunately having a Wix# entity with a generic transparent interface for both cases is close to impossible. Despite reserving the same XML element Shortcut both use cases use completely different set of attributes so two different classes serving the use-case.

> project.UI = WUI.WixUI_InstallDir;
Project.UI defines the type of the MSI User Interface. This value is assigned to the UIRef WiX element during the compilation. And WUI is the enum defining supported types of native MSI UI.
Viewing all 1354 articles
Browse latest View live


Latest Images

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