SimpleGitVersion.SimpleRepositoryInfo.FormatAssemblyVersionAttributesFile C# (CSharp) Method

FormatAssemblyVersionAttributesFile() public static method

Formats the assembly version attributes file.
public static FormatAssemblyVersionAttributesFile ( string majorMinor, string fileVersion, string semVer, string toolName, string assemblyInformationalVersionInfo ) : string
majorMinor string The major.minor: this is used for the AssemblVersion.
fileVersion string The file version (4 numbers between 0 and 65535.
semVer string The semantic version version.
toolName string Name of the tool.
assemblyInformationalVersionInfo string The assembly informational version information.
return string
        public static string FormatAssemblyVersionAttributesFile( 
            string majorMinor, 
            string fileVersion, 
            string semVer, 
            string toolName, 
            string assemblyInformationalVersionInfo )
        {
            return string.Format( _format,
                majorMinor,
                fileVersion,
                assemblyInformationalVersionInfo,
                semVer,
                DateTime.UtcNow.ToString( "u" ),
                SGVSemVer,
                toolName );
        }

Usage Example

Beispiel #1
0
        public override bool Execute()
        {
            try
            {
                string text = SimpleRepositoryInfo.FormatAssemblyVersionAttributesFile(MajorMinor, AssemblyFileVersionInfo, SemVer, "SimpleGitVersionTask", AssemblyInformationalVersionInfo);
                this.LogInfo(string.Format("SimpleGitVersionTask ({3}): AssemblyVersion = '{0}', AssemblyFileVersion = '{1}', AssemblyInformationalVersion = '{2}'.", MajorMinor, AssemblyFileVersionInfo, AssemblyInformationalVersionInfo, SimpleRepositoryInfo.SGVSemVer));
                if (!Directory.Exists(IntermediateOutputPath))
                {
                    this.LogInfo(string.Format("Creating IntermediateOutputPath='{0}' directory.", IntermediateOutputPath));
                    Directory.CreateDirectory(IntermediateOutputPath);
                }

                AssemblyInfoTempFilePath = Path.Combine(IntermediateOutputPath, "SimpleGitVersionTaskAssemblyInfo.g.cs");
                File.WriteAllText(AssemblyInfoTempFilePath, text);
                return(true);
            }
            catch (Exception exception)
            {
                this.LogError("Error occurred: " + exception);
                return(false);
            }
        }