適用於 Azure DevOps 和本地 PC 的發布生成事件 (Post Build event that works on both Azure DevOps and Local PC)


問題描述

適用於 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)

(by Dave PLoLance)

參考文件

  1. Post Build event that works on both Azure DevOps and Local PC (CC BY‑SA 2.5/3.0/4.0)

#azure-devops #post-build-event #post-build #visual-studio-2017






相關問題

Visual Studio Online Build - Visual Studio SDK 和 Modellng SDK (Visual Studio Online Build - Visual Studio SDK and Modellng SDK)

有沒有辦法將現有的“功能”分配給史詩? (Is there a way to assign existing "feature" to epic?)

在路徑 Visual Studio Team Services 中找不到 curl (curl was not found in the path Visual Studio Team Services)

遠程 TFS 2015 到 Azure Devops(私有云)遷移 (Remote TFS 2015 to Azure Devops (private cloud) Migration)

無法再推送到 myProject.visualstudio.com (Can't push to myProject.visualstudio.com anymore)

使用 Visual Studio Code 連接 AzureDevOps Git 存儲庫時出現問題 (Issue in connecting AzureDevOps Git repo using Visual Studio Code)

適用於 Azure DevOps 和本地 PC 的發布生成事件 (Post Build event that works on both Azure DevOps and Local PC)

使用 Azure Devops 進行 CI/CD 部署 (CI/CD Deployment Using Azure Devops)

取回我創建的 DevOps 組織的所有權 (Get back ownership of DevOps organization that was created by me)

在使用源代碼管理時,我如何才能對源代碼的不同部分的用戶組擁有不同的權限? (While using source control, how can I have different permissions for groups of users for different parts of the source code?)

在 Azure DevOps 中自動更改用戶的訪問級別 (Automatically change access level on a user in Azure DevOps)

Azure DevOps Powershell 獲取與構建管道相關的工作項 (Azure DevOps Powershell get work item related to build pipeline)







留言討論