////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //Use: Registry-Free Install / Uninstall
 //
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public static string InstallRegistryFree(
     IDictionary stateSaver,
     RegFreeMode mode,
     string version)
 {
     return(InstallRegistryFree(stateSaver, Assembly.GetExecutingAssembly(), mode, version));
 }
        public static string InstallRegistryFree(
            IDictionary stateSaver,
            Assembly Asm,
            RegFreeMode mode,
            string version)
        {
            try
            {
                FileInfo asmFile = new FileInfo(Asm.Location);

                FileInfo addinFile = null;

                foreach (FileInfo fileInfo in asmFile.Directory.GetFiles())
                {
                    if (fileInfo.Extension.ToLower() == ".addin")
                    {
                        addinFile = fileInfo;
                        break;
                    }
                }

                if (addinFile == null)
                {
                    throw new InstallException();
                }

                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(addinFile.FullName);

                XmlNode node = xmldoc.GetElementsByTagName("Assembly")[0];

                if (node == null)
                {
                    throw new InstallException();
                }

                node.InnerText = asmFile.FullName;

                string addinFilenameDest = GenerateAddinFileLocation(mode, version);

                if (!Directory.Exists(addinFilenameDest))
                {
                    Directory.CreateDirectory(addinFilenameDest);
                }

                addinFilenameDest += addinFile.Name;

                if (File.Exists(addinFilenameDest))
                {
                    File.Delete(addinFilenameDest);
                }

                // copy the addin to target folder according to OS type and all users/separate users
                xmldoc.Save(addinFilenameDest);

                addinFile.Delete();

                return(addinFilenameDest);
            }
            catch
            {
                throw new InstallException("Error installing .addin file!");
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Use: Generates path for .addin file
        //
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static string GenerateAddinFileLocation(RegFreeMode mode, string version)
        {
            string user = System.Environment.UserName;

            string os = CommonUtils.GetOsVersion(false);

            switch (mode)
            {
            case RegFreeMode.kVersionIndep:

                switch (os)
                {
                case "Windows XP":
                    return(@"C:\Documents and Settings\All Users\Application Data\Autodesk\Inventor Addins\");

                case "Windows Vista":
                case "Windows 7":
                    return(@"C:\ProgramData\Autodesk\Inventor Addins\");

                default:
                    break;
                }
                break;

            case RegFreeMode.kVersionDep:

                switch (os)
                {
                case "Windows XP":
                    return(@"C:\Documents and Settings\All Users\Application Data\Autodesk\" + version + "\\Addins\\");

                case "Windows Vista":
                case "Windows 7":
                    return(@"C:\ProgramData\Autodesk\" + version + "\\Addins\\");

                default:
                    break;
                }
                break;

            case RegFreeMode.kUserOverride:
                switch (os)
                {
                case "Windows XP":
                    return(@"C:\Documents and Settings\" + user + @"\Application Data\Autodesk\" + version + "\\Addins\\");

                case "Windows Vista":
                case "Windows 7":
                    return(@"C:\Users\" + user + @"\AppData\Roaming\Autodesk\" + version + "\\Addins\\");

                default:
                    break;
                }
                break;

            default:
                break;
            }

            throw new InstallException();
        }
Esempio n. 4
0
        public static string InstallRegistryFree(
            IDictionary stateSaver,  
            Assembly Asm,
            RegFreeMode mode,
            string version)
        {
            try
            {
                FileInfo asmFile = new FileInfo(Asm.Location);

                FileInfo addinFile = null;

                foreach (FileInfo fileInfo in asmFile.Directory.GetFiles())
                {
                    if (fileInfo.Extension.ToLower() == ".addin")
                    {
                        addinFile = fileInfo;
                        break;
                    }
                }

                if (addinFile == null)
                {
                    throw new InstallException();
                }

                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(addinFile.FullName);

                XmlNode node = xmldoc.GetElementsByTagName("Assembly")[0];

                if (node == null)
                {
                    throw new InstallException();
                }

                node.InnerText = asmFile.FullName;

                string addinFilenameDest = GenerateAddinFileLocation(mode, version);

                if(!Directory.Exists(addinFilenameDest))
                    Directory.CreateDirectory(addinFilenameDest);

                addinFilenameDest += addinFile.Name;

                if (File.Exists(addinFilenameDest))
                    File.Delete(addinFilenameDest);

                // copy the addin to target folder according to OS type and all users/separate users
                xmldoc.Save(addinFilenameDest);

                addinFile.Delete();

                return addinFilenameDest;
            }
            catch
            {
                throw new InstallException("Error installing .addin file!");
            }
        }
Esempio n. 5
0
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //Use: Registry-Free Install / Uninstall
 //
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public static string InstallRegistryFree(
     IDictionary stateSaver,
     RegFreeMode mode,
     string version)
 {
     return InstallRegistryFree(stateSaver, Assembly.GetExecutingAssembly(), mode, version);
 }
Esempio n. 6
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Use: Generates path for .addin file
        //
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public static string GenerateAddinFileLocation(RegFreeMode mode, string version)
        {
            string user = System.Environment.UserName;

            string os = Autodesk.ADN.Utility.WinUtils.CommonUtils.GetOsVersion(false);

            switch (mode)
            {
                case RegFreeMode.kVersionIndep:

                    switch (os)
                    {
                        case "Windows XP":
                            return @"C:\Documents and Settings\All Users\Application Data\Autodesk\Inventor Addins\";

                        case "Windows Vista":
                        case "Windows 7":
                            return @"C:\ProgramData\Autodesk\Inventor Addins\";

                        default:
                            break;
                    }
                    break;

                case RegFreeMode.kVersionDep:

                    switch (os)
                    {
                        case "Windows XP":
                            return @"C:\Documents and Settings\All Users\Application Data\Autodesk\" + version + "\\Addins\\";

                        case "Windows Vista":
                        case "Windows 7":
                            return @"C:\ProgramData\Autodesk\" + version + "\\Addins\\";

                        default:
                            break;
                    }
                    break;

                case RegFreeMode.kUserOverride:
                    switch (os)
                    {
                        case "Windows XP":
                            return @"C:\Documents and Settings\" + user + @"\Application Data\Autodesk\" + version + "\\Addins\\";

                        case "Windows Vista":
                        case "Windows 7":
                            return @"C:\Users\" + user + @"\AppData\Roaming\Autodesk\" + version + "\\Addins\\";

                        default:
                            break;
                    }
                    break;

                default:
                    break;
            }

            throw new InstallException();
        }