Heinrich Ulbricht
Heinrich Ulbricht

Reputation: 10362

Azure Pipelines: How to provide app.config?

Currently I'm building a (pet) .NET project locally. The code is managed via Git. What's local is my app.config containing credentials in the appSettings section used in unit tests. I don't want to commit this.

Now I want to move to Azure Pipelines to set up automated builds. Of course I don't want to commit my app.config so currently it is missing and the build fails because of that.

How would I create the app.config (or something similar?) in Azure Pipelines?

Upvotes: 1

Views: 1003

Answers (1)

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41755

You can store the credentials in the Build pipeline variables (make the password secret), then write a PowerShell script that create the app.config file and take the credentials from the variables.

PowerShell can use the variables in this way:

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

Run the PowerShell during the build (with PowerShell task) and you will get your app.config file.

Upvotes: 1

Related Questions