C24.ReVersion.Versioner.SetVersionForProject C# (CSharp) Method

SetVersionForProject() private method

private SetVersionForProject ( string projectPath, System.Version defaultVersion, string additionalInfo ) : void
projectPath string
defaultVersion System.Version
additionalInfo string
return void
        private void SetVersionForProject(string projectPath, Version defaultVersion, string additionalInfo)
        {
            var helper = new ProjectPathHelper(this.fileSystem);

            this.output.WriteLine("Processing project '{0}'...", projectPath);

            this.output.WriteLine("-> Reading version...");
            Version version;
            if (!helper.TryRetrieveVersion(projectPath, out version))
            {
                version = defaultVersion;
            }

            this.output.WriteLine("-> Reading assembly info...");
            string assemblyInfoFile = helper.GetAssemblyInfoFileName(projectPath);
            string assemblyInfo = this.fileSystem.FileExists(assemblyInfoFile) ? this.fileSystem.ReadAllText(assemblyInfoFile) : string.Empty;

            this.output.WriteLine("-> AddingReplacing version information...");
            var modifier = new AssemblyInfoModifier();
            assemblyInfo = modifier.ReplaceAssemblyAttribute(assemblyInfo, typeof(AssemblyVersionAttribute), version.ToString());
            assemblyInfo = modifier.ReplaceAssemblyAttribute(assemblyInfo, typeof(AssemblyFileVersionAttribute), version.ToString());

            if (additionalInfo != null)
            {
                this.output.WriteLine("-> Adding/Replacing additional information...");
                assemblyInfo = modifier.ReplaceAssemblyAttribute(assemblyInfo, typeof(AssemblyInformationalVersionAttribute), additionalInfo);
            }

            this.output.WriteLine("-> Saving assembly info...");
            this.fileSystem.WriteAllText(assemblyInfoFile, assemblyInfo);

            this.output.WriteLine("Processing project finished.");
        }
    }