Ejemplo n.º 1
0
        private void ModifyAssemblyFileVersion(AssemblyInfoWriter writer, AssemblyInfoReader reader)
        {
            Log.LogMessage(MessageImportance.Normal,
                           string.Format("Modifying AssemblyFileVersion with pattern: {0}", AssemblyVersionPattern));

            try
            {
                string newValue = new PatternBasedParser().Replace(reader.GetAssemblyFileVersion(), AssemblyFileVersionPattern);

                writer.ModifyAssemblyFileVersionTo(newValue);
            }
            catch (ApplicationException exception)
            {
                Log.LogErrorFromException(exception);
            }
        }
        public void When_trying_to_get_the_current_assembly_version_from_the_assemblyinfo_it_should_return()
        {
            // ----------------------------------------------------------------
            // ARRANGE
            //-----------------------------------------------------------------
            string assemblyInfoFile = AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\AssemblyInfoToReadFrom.txt";
            var parser = new AssemblyInfoReader(assemblyInfoFile);

            // ----------------------------------------------------------------
            // ACT
            //-----------------------------------------------------------------
            string assemblyVersion = parser.GetAssemblyVersion();

            // ----------------------------------------------------------------
            // ASSERT
            //-----------------------------------------------------------------
            Assert.AreEqual("1.2.3.4.5.6.7.8", assemblyVersion);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Start the task by calling it with MSBuild 
        /// </summary>
        public override bool Execute()
        {
            var reader = new AssemblyInfoReader(AssemblyInfoPath);
            var writer = new AssemblyInfoWriter(AssemblyInfoPath);

            if (!string.IsNullOrEmpty(AssemblyVersionPattern))
            {
                ModifyAssemblyVersion(writer, reader);
            }

            if (!string.IsNullOrEmpty(AssemblyFileVersionPattern))
            {
                ModifyAssemblyFileVersion(writer, reader);
            }

            if (!string.IsNullOrEmpty(AssemblyInformationalVersion))
            {
                ModifyAssemblyInformationalVersion(writer, reader);
            }

            return true;
        }