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

New Post: Files in InstallDir

$
0
0
Aha, that worked!
However, I needed to set TargetDir as well.
So for others, the following example works. The %ProgramFiles% will be ignored, the file will be paced in InstallDir/TargetDir and the sub directories placed accordingly.
            static public void Main()
            {
                try
                {
                    var msiProject = new ManagedProject("My App",
                        new Dir(@"%ProgramFiles%\My Company\My Product", new File(@"Files\myapp.exe")),
                        new Dir("SubDirRoot", new File(@"Files\myapp.exe"),
                        new Dir("SubDirLevel1", new File(@"Files\myapp.exe"))),
                        new Dir("SubDirRoot2", new File(@"Files\myapp.exe")));
                    msiProject.Version = new Version(1, 0, DateTime.Now.Year, DateTime.Now.Month);
                    msiProject.Platform = Platform.x64;
                    msiProject.OutFileName = "MyApp " + msiProject.Platform.ToString();
                    msiProject.GUID = new Guid("B5C99E99-39E8-4417-9391-14B3E28E1432");
                    msiProject.SetNetFxPrerequisite("NETFRAMEWORK40FULL='#1'");
                    msiProject.Load += (e) =>
                    {
                        if (e.IsInstalling)
                        {
                            e.Session.Log("Begin WIXSharp CustomAction SetInstalldir");
                            RegistryKey consoleKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Help\\v1.0");
                            if (consoleKey != null)
                            {
                                string consolefolder = Convert.ToString(consoleKey.GetValue("AppRoot", string.Empty));
                                e.Session.Log("Setting INSTALLDIR to Help folder '" + consolefolder + "'");
                                e.Session["INSTALLDIR"] = consolefolder;
                                e.Session["TARGETDIR"] = consolefolder;
                            }
                            e.Session.Log("End WixSharp CustomAction SetInstalldir");
                        }
                    };
                    Compiler.PreserveTempFiles = true;
                    Compiler.BuildMsi(msiProject);
                }
                catch (Exception)
                {

                    throw;
                }
            }
        }
Best regards
Flemming

Viewing all articles
Browse latest Browse all 1354

Trending Articles



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