Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Visual Studio Online でビルドする際に、アセンブリに Git のコミットハッシュを埋め込むためのスクリプト
$ASSEMBLY_INFO_PATH = "$env:SYSTEM_DEFAULTWORKINGDIRECTORY\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, $env:BUILD_SOURCEVERSION.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