Change nuget.config location using environment variable in dotnet tool restore

354 views Asked by At

I have a Github action that is running dotnet tool restore on my repo however I'm not able to modify this command and pass in the -configFile parameter. Is there a way I can supply an absolute path to my custom nuget.config file via an environment variable?

I tried setting the NUGET_RESTORE_MSBUILD_ARGS environment variable hoping NuGet would pick it up but that hasn't worked.

I tried adding it to my github action directly:

name: My github action
on: pull_request
env:
  NUGET_RESTORE_MSBUILD_ARGS: /p:RestoreConfigFile=/home/runner/work/MyProj/CustomFolder/nuget.config
jobs:
  ...

As well as setting its value dynamically within the action using:

- run: echo "NUGET_RESTORE_MSBUILD_ARGS=/p:RestoreConfigFile=/home/runner/work/MyProj/CustomFolder/nuget.config" >> $GITHUB_ENV
0

There are 0 answers