簡體   English   中英

需要在安裝程序的名稱中指定最新的 git hash

[英]Latest git hash needs to be speicified in installer's name

考慮一種情況,Git 安裝在 Windows 中,並且僅在 Git Bash 中可用,而不是 Windows cmd 環境。 使用 vdproj 為應用程序創建安裝程序,但需要將最新的 git 哈希插入到 MSI 包的名稱中。 例如,目前它產生: Behnama.msi 但我們需要它產生: Behnama_49ee23d3b33ba0fa5ce0ac128f50ed00345e9ce3.msi 哈希 49ee... 是我在 Git Bash 中輸入 'git log' 時的頂部。 創建新提交時,然后來構建 vdproj,我希望以 msi 文件的名稱更改哈希。

VDPROJ 不是基於 MSBuild,所以它不能做那么多。 最好的辦法是使用 postbuild 命令將 Product.msi 重命名為 Product_%SHA%.msi。

一個解決方案是安裝 ActivePerl 或任何 perl 二進制文件以便能夠運行 perl 腳本。 然后將其作為構建后事件運行。 這個 perl 腳本可以獲得我想要的哈希值:

$folder = '';
while (! -d "$folder.git") {
    $folder .= '../';
}
open IF, "$folder.git/logs/HEAD" or die $!;
while (<IF>) {
    s/\s+$//;
    $lastline = $_ if $_;
}
close IF;
@ar = split /\s+/, $lastline;
print "$ar[1]\n";

最后一條語句可能是這樣的:

rename("Behnama.msi", "Behnama_$ar[1].msi");

反而。

你需要幾步

  1. 獲取最后一個 git commit ID
  2. 將 ID 寫入 wxi 文件
  3. 將 wxi 文件包含到原始 wxs 文件中
  4. 使用值作為變量

對於 1) 您可以使用git log -1 --pretty=format:"%h" (short hash) 或git log -1 --pretty=format:"%H" (long hash)來獲取最后的提交 ID。

對於 2) 在 Windows 系統上鍵入git log -1 --pretty=format:"%H" > gitLastCommit.wxi將最后一次提交存儲為 wxi 文件。 提示:您需要用<include><?define mylastGitCommit = "VALUE OF COMMT ID" ?></include>包裝簡單的 ID

對於 3) 將類似的行<?include .\\gitLastCommit.wxi ?>到您的 wxs 文件。

對於 4) 在需要它的 wxs 文件中使用定義的變量$(var.mylastGitCommit)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM