Inheritance: IEnvironmentRepository
Ejemplo n.º 1
0
        public void Uninstall(MachineWideUninstallation mwUninstl)
        {
            if (mwUninstl == null)
            {
                throw new ArgumentNullException("mwUninstl");
            }

            mwUninstl.OnPreparing();

            if (!HasBeenInstalled(mwUninstl.Prerequisite))
            {
                mwUninstl.OnCompleted(MachineWideProcessResults.Skipped);
                return;
            }

            if (!mwUninstl.IsPrigSourceUninstallationDisabled)
            {
                UninstallAllSources(mwUninstl);
            }
            UnregisterProfiler(mwUninstl);
            UnregisterEnvironmentVariables(mwUninstl);
            UnregisterNuGetSource(mwUninstl);
            EnvironmentRepository.UnregisterToolsPath();
            EnvironmentRepository.UnregisterPackageFolder();

            mwUninstl.OnCompleted(MachineWideProcessResults.Completed);
        }
Ejemplo n.º 2
0
        public bool HasBeenInstalled(MachinePrerequisite machinePreq)
        {
            if (machinePreq == null)
            {
                throw new ArgumentNullException("machinePreq");
            }

            var profLocs = EnvironmentRepository.GetProfilerLocations();

            if (profLocs == null || profLocs.Length == 0)
            {
                return(false);
            }

            foreach (var profLoc in profLocs)
            {
                using (var classesRootKey = EnvironmentRepository.OpenRegistryBaseKey(RegistryHive.ClassesRoot, profLoc.RegistryView))
                    using (var inprocServer32Key = EnvironmentRepository.OpenRegistrySubKey(classesRootKey, ProfilerLocation.InprocServer32Path))
                    {
                        machinePreq.OnProfilerStatusChecking(profLoc);
                        if (!IsProfilerInstalled(inprocServer32Key, ProfilerLocation.GetExpectedFileDescription(machinePreq.PackageVersion)))
                        {
                            return(false);
                        }
                    }
            }
            return(true);
        }
Ejemplo n.º 3
0
        public void Install(MachineWideInstallation mwInstl)
        {
            if (mwInstl == null)
            {
                throw new ArgumentNullException("mwInstl");
            }

            mwInstl.OnPreparing();

            if (HasBeenInstalled(mwInstl.Prerequisite))
            {
                mwInstl.OnCompleted(MachineWideProcessResults.Skipped);
                return;
            }

            EnvironmentRepository.RegisterPackageFolder();
            EnvironmentRepository.RegisterToolsPath();
            CreateNupkg(mwInstl);
            RegisterNuGetSource(mwInstl);
            RegisterEnvironmentVariables(mwInstl);
            RegisterProfiler(mwInstl);
            if (!mwInstl.IsPrigSourceInstallationDisabled)
            {
                InstallDefaultSource(mwInstl);
            }

            mwInstl.OnCompleted(MachineWideProcessResults.Completed);
        }
Ejemplo n.º 4
0
 void InstallDefaultSource(MachineWideInstallation mwInstl)
 {
     var msvsdirPath = new DirectoryInfo(@"C:\Program Files (x86)").EnumerateDirectories("Microsoft Visual Studio *").
                       Where(_ => Regex.IsMatch(_.Name, @"Microsoft Visual Studio \d+\.\d+")).
                       OrderByDescending(_ => _.Name).
                       Select(_ => _.FullName).
                       First();
     {
         var pkgName = "TestWindow";
         var src     = Path.Combine(msvsdirPath, @"Common7\IDE\CommonExtensions\Microsoft\TestWindow");
         mwInstl.OnPrigSourceInstalling(pkgName, src);
         var stdout = PrigExecutor.StartInstalling(pkgName, src);
         mwInstl.OnPrigSourceInstalled(stdout);
     }
     {
         var pkgName = "TestWindow1";
         var src     = Path.Combine(msvsdirPath, @"Common7\IDE\CommonExtensions\Microsoft\TestWindow\x64");
         if (EnvironmentRepository.ExistsDirectory(src))
         {
             mwInstl.OnPrigSourceInstalling(pkgName, src);
             var stdout = PrigExecutor.StartInstalling(pkgName, src);
             mwInstl.OnPrigSourceInstalled(stdout);
         }
     }
 }
Ejemplo n.º 5
0
        void InstallDefaultSource(MachineWideInstallation mwInstl)
        {
            var query = from envVar in EnvironmentRepository.GetEnvironmentVariables()
                        where Regex.IsMatch(envVar.Key, @"VS\d{3}COMNTOOLS", RegexOptions.IgnoreCase)
                        select envVar;

            foreach (var envVar in query)
            {
                var vsComnToolsPathName = envVar.Key;
                var vsComnToolsPath     = envVar.Value;

                var msvsdirPath = Path.Combine(vsComnToolsPath, @"..\..");
                {
                    var pkgName = "TestWindow_" + vsComnToolsPathName;
                    var src     = Path.Combine(msvsdirPath, @"Common7\IDE\CommonExtensions\Microsoft\TestWindow");
                    if (EnvironmentRepository.ExistsDirectory(src))
                    {
                        mwInstl.OnPrigSourceInstalling(pkgName, src);
                        var stdout = PrigExecutor.StartInstalling(pkgName, src);
                        mwInstl.OnPrigSourceInstalled(stdout);
                    }
                }
                {
                    var pkgName = "TestWindow64_" + vsComnToolsPathName;
                    var src     = Path.Combine(msvsdirPath, @"Common7\IDE\CommonExtensions\Microsoft\TestWindow\x64");
                    if (EnvironmentRepository.ExistsDirectory(src))
                    {
                        mwInstl.OnPrigSourceInstalling(pkgName, src);
                        var stdout = PrigExecutor.StartInstalling(pkgName, src);
                        mwInstl.OnPrigSourceInstalled(stdout);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        void RegisterNuGetSource(MachineWideInstallation mwInstl)
        {
            var toolsPath = EnvironmentRepository.GetToolsPath();
            var name      = "Prig Source";

            mwInstl.OnNuGetSourceRegistering(name, toolsPath);
            var stdout = NuGetExecutor.StartSourcing(name, toolsPath);

            mwInstl.OnNuGetSourceRegistered(stdout);
        }
Ejemplo n.º 7
0
        void CreateNupkg(MachineWideInstallation mwInstl)
        {
            var toolsPath = EnvironmentRepository.GetToolsPath();
            var pkgName   = "Prig";

            mwInstl.OnNuGetPackageCreating(pkgName);
            var nugetPackageFolder = Path.Combine(toolsPath, "NuGet");
            var stdout             = NuGetExecutor.StartPacking(Path.Combine(nugetPackageFolder, "Prig.nuspec"), toolsPath);

            mwInstl.OnNuGetPackageCreated(stdout);
        }
Ejemplo n.º 8
0
 void UnregisterEnvironmentVariables(MachineWideUninstallation mwUninstl)
 {
     {
         var name = EnvironmentRepository.GetPackageFolderKey();
         mwUninstl.OnEnvironmentVariableUnregistering(name);
         EnvironmentRepository.RemovePackageFolder();
         mwUninstl.OnEnvironmentVariableUnregistered(name);
     }
     {
         var name = EnvironmentRepository.GetLogFolderKey();
         mwUninstl.OnEnvironmentVariableUnregistering(name);
         EnvironmentRepository.RemoveLogFolder();
         mwUninstl.OnEnvironmentVariableUnregistered(name);
     }
 }
Ejemplo n.º 9
0
        bool IsProfilerInstalled(RegistryKey inprocServer32Key, string expectedFileDesc)
        {
            if (inprocServer32Key == null)
            {
                return(false);
            }

            var profPath = (string)EnvironmentRepository.GetRegistryValue(inprocServer32Key, null);

            if (!EnvironmentRepository.ExistsFile(profPath))
            {
                return(false);
            }

            return(EnvironmentRepository.GetFileDescription(profPath) == expectedFileDesc);
        }
Ejemplo n.º 10
0
        void UnregisterProfiler(MachineWideUninstallation mwUninstl)
        {
            var profLocs = EnvironmentRepository.GetProfilerLocations();

            if (profLocs == null || profLocs.Length == 0)
            {
                return;
            }

            foreach (var profLoc in EnvironmentRepository.GetProfilerLocations())
            {
                mwUninstl.OnProfilerUnregistering(profLoc);
                var stdout = Regsvr32Executor.StartUninstalling(profLoc.PathOfInstalling);
                mwUninstl.OnProfilerUnregistered(stdout);
            }
        }
Ejemplo n.º 11
0
 void RegisterEnvironmentVariables(MachineWideInstallation mwInstl)
 {
     {
         var pkgDir = EnvironmentRepository.GetPackageFolder();
         var name   = EnvironmentRepository.GetPackageFolderKey();
         var value  = pkgDir;
         mwInstl.OnEnvironmentVariableRegistering(name, value);
         EnvironmentRepository.StorePackageFolder(value);
         mwInstl.OnEnvironmentVariableRegistered(name, value);
     }
     {
         var logDir = EnvironmentRepository.GetLogFolder();
         var name   = EnvironmentRepository.GetLogFolderKey();
         var value  = logDir;
         mwInstl.OnEnvironmentVariableRegistering(name, value);
         EnvironmentRepository.StoreLogFolder(value);
         mwInstl.OnEnvironmentVariableRegistered(name, value);
     }
 }
Ejemplo n.º 12
0
 void RegisterEnvironmentVariables(MachineWideInstallation mwInstl)
 {
     {
         var pkgDir = EnvironmentRepository.GetPackageFolder();
         var name   = EnvironmentRepository.GetPackageFolderKey();
         var value  = pkgDir;
         mwInstl.OnEnvironmentVariableRegistering(name, value);
         EnvironmentRepository.StorePackageFolder(value);
         mwInstl.OnEnvironmentVariableRegistered(name, value);
     }
     {
         var logDir = EnvironmentRepository.GetLogFolder();
         var name   = EnvironmentRepository.GetLogFolderKey();
         var value  = logDir;
         mwInstl.OnEnvironmentVariableRegistering(name, value);
         EnvironmentRepository.StoreLogFolder(value);
         EnvironmentRepository.CreateDirectory(value);
         EnvironmentRepository.SetFullControlPermissionsToEveryone(value);
         mwInstl.OnEnvironmentVariableRegistered(name, value);
     }
 }