예제 #1
0
        /// <summary>
        ///   Determines if one of <c>AssemblyVersionType</c> assembly infos
        ///   should be updated.
        /// </summary>
        /// <param name="projectInfo">
        ///   <c>ProjectInfo</c> for the project that is considered.
        /// </param>
        /// <param name="assemblyVersionType">
        ///   <c>AssemblyVersionType</c> for which version update is determined.
        /// </param>
        /// <param name="highestProjectVersion">
        ///   Highest <c>ProjectVersion</c> used as a reference for update.
        /// </param>
        /// <returns>
        ///   <c>true</c> if version should be incremented.
        /// </returns>
        private bool ShouldUpdateOneOfAssemblyVersionTypes(ProjectInfo projectInfo, AssemblyVersionType assemblyVersionType, ProjectVersion highestProjectVersion)
        {
            Debug.Assert(assemblyVersionType == AssemblyVersionType.AssemblyVersion || assemblyVersionType == AssemblyVersionType.AssemblyFileVersion || assemblyVersionType == AssemblyVersionType.AssemblyInformationalVersion);
            // first check if corresponding assembly version type exists at all
            if (projectInfo.CurrentAssemblyVersions[assemblyVersionType] == ProjectVersion.Empty)
            {
                return(false);
            }
            // else, depending on settings
            switch (m_numberingOptions.BatchCommandIncrementScheme)
            {
            case (BatchCommandIncrementScheme.IncrementModifiedIndependently):
                return(projectInfo.IsMarkedForUpdate(assemblyVersionType));

            case (BatchCommandIncrementScheme.IncrementAllIndependently):
                return(true);

            case (BatchCommandIncrementScheme.IncrementModifiedOnlyAndSynchronize):
                int resetBuildAndRevisionValues = (int)m_numberingOptions.ResetBuildAndRevisionTo;
                return(projectInfo.Modified || ProjectVersion.ApplyVersionPattern(highestProjectVersion.ToString(), projectInfo.CurrentAssemblyVersions[assemblyVersionType].ToString(), resetBuildAndRevisionValues) != projectInfo.CurrentAssemblyVersions[assemblyVersionType].ToString());//projectInfo.CurrentAssemblyVersions[assemblyVersionType] < highestProjectVersion;

            case (BatchCommandIncrementScheme.IncrementAllAndSynchronize):
                int buildAndRevisionResetValue = (int)m_numberingOptions.ResetBuildAndRevisionTo;
                return(ProjectVersion.ApplyVersionPattern(highestProjectVersion.ToString(), projectInfo.CurrentAssemblyVersions[assemblyVersionType].ToString(), buildAndRevisionResetValue) != projectInfo.CurrentAssemblyVersions[assemblyVersionType].ToString()); // projectInfo.CurrentAssemblyVersions[assemblyVersionType] < highestProjectVersion;
            }
            Debug.Assert(false, "Not supported option");
            return(false);
        }
예제 #2
0
        /// <summary>
        ///   Provides the updated version as a string.
        /// </summary>
        /// <param name="projectInfo">
        ///   <c>ProjectInfo</c> for the project that is updated.
        /// </param>
        /// <param name="assemblyVersionType">
        ///   <c>AssemblyVersionType</c> for which version update is done.
        /// </param>
        /// <param name="highestProjectVersion">
        ///   Highest <c>ProjectVersion</c> used as a reference for update.
        /// </param>
        /// <returns>
        ///   New version as a string.
        /// </returns>
        public string ProvideNewVersion(ProjectInfo projectInfo, AssemblyVersionType assemblyVersionType, ProjectVersion highestProjectVersion)
        {
            Debug.Assert(assemblyVersionType != AssemblyVersionType.All);
            switch (m_numberingOptions.BatchCommandIncrementScheme)
            {
            case BatchCommandIncrementScheme.IncrementModifiedIndependently:
            case BatchCommandIncrementScheme.IncrementAllIndependently:
                if (m_numberingOptions.SynchronizeAllVersionTypes && !projectInfo.ToUpdate)
                {
                    return(projectInfo.CurrentAssemblyVersions.HighestProjectVersion.ToString());
                }
                return(projectInfo.ToBecomeAssemblyVersions[assemblyVersionType].ToString());

            case (BatchCommandIncrementScheme.IncrementAllAndSynchronize):
            case (BatchCommandIncrementScheme.IncrementModifiedOnlyAndSynchronize):
                int resetBuildAndRevisionValues = (int)m_numberingOptions.ResetBuildAndRevisionTo;
                return(ProjectVersion.ApplyVersionPattern(highestProjectVersion.ToString(), projectInfo.CurrentAssemblyVersions[assemblyVersionType].ToString(), resetBuildAndRevisionValues));// highestProjectVersion.ToString();
            }
            Debug.Assert(false, "Not supported option");
            return(null);
        }