問題描述
適用於 Azure DevOps 和本地 PC 的發布生成事件 (Post Build event that works on both Azure DevOps and Local PC)
我有一個 VS2017 解決方案,它既可以在本地構建,也可以在 Azure DevOps 上構建。
我現在需要運行 Post Build 腳本來運行 EXE。我在我的本地機器上有這個工作,但我想已經添加到 DevOps 庫的 EXE 路徑會有問題。
注意。EXE 全部安裝在 DevOps 上並從命令行任務運行良好 ‑ 我只需要它作為項目之一的後期構建運行,以便該項目準備好打包到 Installer SetUp 項目中。(在完整的解決方案構建期間)。
這代表本地後期構建腳本 ‑ 如何在 Azure 上處理此問題,路徑會有所不同?
“C:\Program Files (x86)\{dir}\{app}.exe” ‑文件"$(ProjectDir){文件。txt}”
任何幫助表示讚賞。謝謝!
參考解法
方法 1:
This represents the Local Post Build script ‑ How do I handle this on Azure, where the path will be different?
$(ProjectDir)
is msbuild property, so it works on both Azure DevOps and Local PC. You only need to pay attention to the {dir}
of the xx.exe
.
My suggestion is to put the exe in solution folder (where the xx.sln file exists), then you can use script like "$(SolutionDir)\{app}.exe" ‑file "$(ProjectDir){file.txt}"
. The $(SolutionDir)
and $(ProjectDir)
can be recognized by msbuild. (It works for both local pc and online devops.)
Or you can put the xx.exe
under root directory of your git repo, then use $(System.DefaultWorkingDirectory) as the path of your xx.exe
, but it only works for online devops, it can't work on local PC. (Not recommended)