Skip to content

Instantly share code, notes, and snippets.

@chiguniiita
Last active February 5, 2017 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiguniiita/02c7c0c69d8508cec6c838298ca29603 to your computer and use it in GitHub Desktop.
Save chiguniiita/02c7c0c69d8508cec6c838298ca29603 to your computer and use it in GitHub Desktop.
Visual Studio Online でビルドする際に、アセンブリに Git のコミットハッシュを埋め込むためのスクリプト
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