Last active
August 29, 2015 14:11
-
-
Save 3F/b7151892d50bf63df686 to your computer and use it in GitHub Desktop.
Automatic Version Numbering for VSIX Package (vsixmanifest) with vsSolutionBuildEvent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[" | |
Updating version | |
"] | |
#[var ver = #[File get("_version")]] | |
#[var tpl = #[File get("Version.tpl")]] | |
#[var vsSBEDir = $($(ProjectDir:$(SolutionName)))] | |
#[var tStart = $([System.DateTime]::Parse("2015/01/15").ToBinary())] | |
#[var tNow = $([System.DateTime]::UtcNow.Ticks)] | |
#[var revBuild = $([System.TimeSpan]::FromTicks($([MSBuild]::Subtract(#[var tNow], #[var tStart]))).TotalMinutes.ToString("0"))] | |
#[var cs = $(tpl.Replace(%Version%, "$(ver.Replace(".", ", ")), #[var revBuild]"))] | |
#[var cs = $(cs.Replace(%VersionRevString%, "$(ver).#[var revBuild]").Replace(%VersionString%, "$(ver)"))] | |
#[( #[File exists.directory(".git")] && #[File exists.file("git.exe", true)] ) { | |
#[var branchSha1 = #[File sout("git", "rev-parse --short HEAD")]] | |
#[var branchName = #[File sout("git", "rev-parse --abbrev-ref HEAD")]] | |
#[var branchRevCount = #[File sout("git", "rev-list HEAD --count")]] | |
#[var cs = $(cs.Replace(%branchName%, "#[var branchName]").Replace(%branchSha1%, "#[var branchSha1]").Replace(%branchRevCount%, "#[var branchRevCount]"))] | |
} | |
else { | |
#[var cs = $(cs.Replace(%branchName%, "-").Replace(%branchSha1%, "-").Replace(%branchRevCount%, "-"))] | |
}] | |
#[File write("#[var vsSBEDir]Version.cs"):#[var cs]] | |
#[" | |
.vsixmanifest | |
"] | |
#[($(Configuration) ~= "_with_revision" || $(Configuration) ~= "CI_") { | |
#[var ver = #[var ver].#[var revBuild]] | |
}] | |
#[File replace.Regexp("#[var vsSBEDir]/source.extension.vsixmanifest", "<Version>[0-9\.]+</Version>", "<Version>#[var ver]</Version>")] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment