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

New Post: Files in InstallDir

$
0
0
Thanks, but you misunderstand me.
I am changing the InstallDir using a custom actions and just wants to add my file to whatever the InstallDir is set to.
In the examples I have seen, the initial folder is set manual like:
new Dir(@"%ProgramFiles%\My Company\My App"
I don't want to put any files in program files or other "manually" specified folder, but just in InstallDir - or subfolders to that.
The following code works, but put the file in %programfiles%\My Company\My App.
        class Script
        {
            static public void Main()
            {
                try
                {
                    var msiProject = new Project("My App",
                        new Dir(@"%ProgramFiles%\My Company\My App",
                        new File(@"Files\myapp.exe")));
                    msiProject.Actions.Add(new ManagedAction("SetInstalldir",
                                        Return.check,
                                        When.Before,
                                        Step.InstallFiles,
                                        Condition.Always));
                    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'");
                    Compiler.PreserveTempFiles = true;
                    Compiler.BuildMsi(msiProject);
                }
                catch (Exception)
                {

                    throw;
                }
            }
        }

        public class CustomActions
        {
            [CustomAction]
            public static ActionResult SetInstalldir(Session session)
            {
                //get the help installation folder
                session.Log("Begin CustomAction SetInstalldir");

                RegistryKey consoleKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Help\\v1.0");
                if (consoleKey != null)
                {
                    string consolefolder = Convert.ToString(consoleKey.GetValue("AppRoot", string.Empty));
                    session.Log("Setting INSTALLDIR to Help folder '" + consolefolder + "'");
                    session["INSTALLDIR"] = consolefolder;
                }
                session.Log("End CustomAction SetInstalldir");
                return ActionResult.Success;
            }
        }
So I am looking for the variable for [INSTALLDIR] to set in new Dir(--->[INSTALLDIR]<---- ??

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>