Exemplo n.º 1
0
        void InstallPackage(ProjectWidePackage pwPkg, Project proj, string pkgId, string pkgVer)
        {
            try
            {
                InstallerEvents.PackageInstalling     += pwPkg.OnPackageInstalling;
                InstallerEvents.PackageInstalled      += pwPkg.OnPackageInstalled;
                InstallerEvents.PackageReferenceAdded += pwPkg.OnPackageReferenceAdded;

                var source             = default(string);
                var ignoreDependencies = false;
                Installer.InstallPackage(source, proj, pkgId, pkgVer, ignoreDependencies);
            }
            finally
            {
                InstallerEvents.PackageInstalling     -= pwPkg.OnPackageInstalling;
                InstallerEvents.PackageInstalled      -= pwPkg.OnPackageInstalled;
                InstallerEvents.PackageReferenceAdded -= pwPkg.OnPackageReferenceAdded;
            }
        }
Exemplo n.º 2
0
        public void Install(ProjectWidePackage pwPkg)
        {
            if (pwPkg == null)
            {
                throw new ArgumentNullException("pwPkg");
            }

            pwPkg.OnPackagePreparing();

            var targetProj = pwPkg.TargetProject;
            var pkgId      = pwPkg.PackageId;
            var pkgVer     = pwPkg.PackageVersion;

            if (!InstallerServices.IsPackageInstalledEx(targetProj, pkgId, pkgVer))
            {
                if (InstallerServices.IsPackageInstalled(targetProj, pkgId))
                {
                    Uninstaller.UninstallPackage(targetProj, pkgId, false);
                }
                InstallPackage(pwPkg, targetProj, pkgId, pkgVer);
            }
        }