【问题标题】:Azure Pipelines: How to provide app.config?Azure Pipelines:如何提供 app.config?
【发布时间】:2019-04-12 19:45:43
【问题描述】:

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

现在我想迁移到 Azure Pipelines 来设置自动化构建。当然我不想提交我的app.config,所以目前它丢失了,因此构建失败。

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

【问题讨论】:

  • 重要术语说明:如果您的测试需要来自 app.config 的凭据,它们不是单元测试。单元测试独立运行,没有依赖关系。

标签: .net azure-devops app-config azure-pipelines


【解决方案1】:

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

PowerShell 可以这样使用变量:

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

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

【讨论】:

    猜你喜欢
    • 2016-03-13
    • 1970-01-01
    • 1970-01-01
    • 2022-07-26
    • 2021-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-11
    相关资源
    最近更新 更多