We have dotnet core application with Nuget.config file . As part of azure devops CI pipeline, we want to read and replace environment variables in Nuget.config file. Environment/Pipeline variables(USERNAME and PWD) are configured in "Build Docker Image" Task in CI pipeline. The azure devops CI build server runs on Ubuntu machine.
Environment variables in MAC/Linux should be replaced in following way as per this documentation.
The syntax "$USERNAME" in Nuget.config is not working here. When we replace static username and password, it works fine.
Nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="abcFeed" value="https://somedevops.com/xyz/packaging/someApps/nuget/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<abcFeed>
<add key="Username" value="$USERNAME"/>
<add key="ClearTextPassword" value="$PWD"/>
</abcFeed>
</packageSourceCredentials>
</configuration>
We have tried below syntax with following documentation, none of them are working: $USERNAME, $(USERNAME), %USERNAME%, $USERNAME$
What is correct syntax or way of replacing environment variables in Nuget.config file with azure devops pipeline?