コード例 #1
0
ファイル: Installer.cs プロジェクト: keutmann/wspbuilder
        /// <summary>
        /// Upgrades a solution using a .wsp file to sharepoint server
        /// </summary>
        /// <param name="solutionFile">the full path to the solution package file</param>
        /// <param name="solutionID">the SolutionId (GUID) of the solution</param>
        /// <returns>true if it was able to upgrade the solution</returns>
        public bool UpgradeSolution(string solutionFile, Guid solutionID)
        {
            try
            {
                if (string.IsNullOrEmpty(solutionFile))
                {
                    throw new Exception("No solution file specified.");
                }
                if (!File.Exists(solutionFile))
                {
                    throw new Exception("Solution file not found.");
                }

                SPSolution solution = SPFarm.Local.Solutions[solutionID];
                KillRunningJobs(solution);

                solution.Upgrade(solutionFile, Immediately);
            }
            catch (NullReferenceException)
            {
                return(false);
            }
            catch (InvalidOperationException) {
                return(DeploySolution(solutionFile, solutionID.ToString()));
            }
            catch (Exception eee)
            {
                throw new Exception("Unable to upgrade solution.", eee);
            }
            return(true);
        }
            protected internal override bool Execute()
            {
                try {
                    string filename = InstallConfiguration.SolutionFile;
                    if (String.IsNullOrEmpty(filename))
                    {
                        throw new InstallException(res.ConfigErrorNoSolution);
                    }

                    SPSolution installedSolution = SPFarm.Local.Solutions [InstallConfiguration.SolutionId];

                    //
                    // Remove existing job, if any.
                    //
                    if (installedSolution.JobExists)
                    {
                        RemoveExistingJob(installedSolution);
                    }

                    log.Info(res.SolutionUpgrade);
                    installedSolution.Upgrade(filename, GetImmediateJobTime());
                    return(true);
                } catch (SqlException ex) {
                    throw new InstallException(ex.Message, ex);
                }
            }
コード例 #3
0
        public static void UpgradeSolution(ISharePointCommandContext context, SolutionInfo solutionInfo)
        {
            SPSolution solution = SPFarm.Local.Solutions[solutionInfo.Name];

            //Do not use this version as it causes SP to return success prior to timer execution so VS falselt notifies the user it is completed. https://cksdev.codeplex.com/workitem/9027
            //solution.Upgrade(solutionInfo.LocalPath, DateTime.Now);

            solution.Upgrade(solutionInfo.LocalPath);
        }
コード例 #4
0
        private void UpgradeSolution(ISharePointCommandContext context, string fullWspPath)
        {
            SPSolution solution = SPFarm.Local.Solutions[Path.GetFileName(fullWspPath)];

            if (solution == null)
            {
                throw new InvalidOperationException("The solution has not been deployed.");
            }

            solution.Upgrade(fullWspPath);
        }
コード例 #5
0
        protected virtual void UpgradeSolution(object modelHost,
                                               SPFarm farm,
                                               SPWebApplication webApplication,
                                               FarmSolutionDefinition definition,
                                               SPSolution existingSolution)
        {
            definition.SetPropertyBagValue("HadUpgradetHit");

            // ensure deployment state first
            TraceService.Information((int)LogEventId.CoreCalls, string.Format("Ensuring deployment state. Solution must be deployed before upgrading."));
            DeploySolution(modelHost, farm, webApplication, definition, existingSolution);

            // upgrade
            var tmpWspDirectory     = string.Format("{0}_{1}", Path.GetFileNameWithoutExtension(definition.FileName), Guid.NewGuid().ToString("N"));
            var tmpWspDirectoryPath = Path.Combine(Path.GetTempPath(), tmpWspDirectory);

            Directory.CreateDirectory(tmpWspDirectoryPath);

            var tmpWspFilPath = Path.Combine(tmpWspDirectoryPath, definition.FileName);

            File.WriteAllBytes(tmpWspFilPath, definition.Content);

            var isNowDeployment = false;

            if (definition.UpgradeDate.HasValue)
            {
                existingSolution.Upgrade(tmpWspFilPath, definition.UpgradeDate.Value);
            }
            else
            {
                existingSolution.Upgrade(tmpWspFilPath, DateTime.Now);
                isNowDeployment = true;
            }

            var deployed = existingSolution.Deployed;

            if (isNowDeployment)
            {
                TraceService.Information((int)LogEventId.CoreCalls, string.Format("Checking .Deployed status to be true"));

                while (!deployed)
                {
                    TraceService.Information((int)LogEventId.CoreCalls,
                                             string.Format("Sleeping [{0}] milliseconds...", SolutionDeploymentTimeoutInMillisecond));
                    Thread.Sleep(SolutionDeploymentTimeoutInMillisecond);

                    TraceService.Information((int)LogEventId.CoreCalls,
                                             string.Format("Checkin .Deployed for solution [{0}] in [{1}] milliseconds...",
                                                           existingSolution.Name, SolutionDeploymentTimeoutInMillisecond));

                    existingSolution = FindExistingSolution(modelHost, farm, webApplication, definition);
                    deployed         = existingSolution.DeploymentState != SPSolutionDeploymentState.NotDeployed;
                }

                existingSolution = FindExistingSolution(modelHost, farm, webApplication, definition);
                TraceService.Information((int)LogEventId.CoreCalls, string.Format("Checking .Deployed status to be false"));
                var jobExists = existingSolution.JobExists;

                while (jobExists)
                {
                    TraceService.Information((int)LogEventId.CoreCalls,
                                             string.Format("Sleeping [{0}] milliseconds...", SolutionDeploymentTimeoutInMillisecond));
                    Thread.Sleep(SolutionDeploymentTimeoutInMillisecond);


                    TraceService.Information((int)LogEventId.CoreCalls,
                                             string.Format("Checkin .JobExists for solution [{0}] in [{1}] milliseconds...",
                                                           existingSolution.Name, SolutionDeploymentTimeoutInMillisecond));

                    existingSolution = FindExistingSolution(modelHost, farm, webApplication, definition);
                    jobExists        = existingSolution.JobExists;
                }

                TraceService.Information((int)LogEventId.CoreCalls, string.Format(".Deployed is true AND .JobExists is false"));
            }
            else
            {
                TraceService.Information((int)LogEventId.CoreCalls, string.Format("Future upgrade. Passing wait."));
            }
        }