Azure管道:如何提供app.config?

问题描述 投票:0回答:1

目前我正在本地构建一个(宠物).NET项目。代码通过Git进行管理。什么是本地的是我的app.config包含在单元测试中使用的appSettings部分的凭据。我不想这样做。

现在,我想转移到Azure管道以设置自动构建。当然我不想提交我的app.config所以目前它已经丢失并且构建因此而失败。

我如何在Azure管道中创建app.config(或类似的东西?)?

.net azure-devops app-config azure-pipelines
1个回答
0
投票

您可以将凭据存储在Build管道变量中(使密码保密),然后编写一个PowerShell脚本来创建app.config文件并从变量中获取凭据。

PowerShell可以这种方式使用变量:

# Assuming the build variables are 'userName' and 'password'
$userName = $env:userName
$password = $env:password

在构建期间运行PowerShell(使用PowerShell任务),您将获得app.config文件。

© www.soinside.com 2019 - 2024. All rights reserved.