Last active
February 5, 2017 12:54
-
-
Save chiguniiita/02c7c0c69d8508cec6c838298ca29603 to your computer and use it in GitHub Desktop.
Visual Studio Online でビルドする際に、アセンブリに Git のコミットハッシュを埋め込むためのスクリプト
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
Param([string]$WORKSPACE) | |
$GIT_COMMIT_HASH = git rev-parse HEAD | |
$ASSEMBLY_INFO_PATH = "$WORKSPACE\src\Playground.Sample\Properties\AssemblyInfo.cs" | |
$ASSEMBLY_INFO_CONTENT = Get-Content $ASSEMBLY_INFO_PATH | |
$ASSEMBLY_VERSION = [regex]::Match($ASSEMBLY_INFO_CONTENT, "AssemblyVersion\(`"(.+?)`"\)").Groups[1].Value | |
$ASSEMBLY_INFORMATIONAL_VERSION = [string]::Format("[assembly: AssemblyInformationalVersion(`"{0}-{1}`")]", $ASSEMBLY_VERSION, $GIT_COMMIT_HASH.Substring(0, 7)) | |
# 取得できたバージョンを表示 | |
Write-Host $ASSEMBLY_INFORMATIONAL_VERSION | |
Add-Content -Path $ASSEMBLY_INFO_PATH -Value $ASSEMBLY_INFORMATIONAL_VERSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment