Open
Description
Task name
DotNetCoreCLI
Task version
2
Environment type (Please select at least one enviroment where you face this issue)
- Self-Hosted
- Microsoft Hosted
- VMSS Pool
- Container
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
No response
Operation system
Windows 11
Task log
N/A
Relevant log output
N/A
Aditional info
When running DotNetCoreCLI@2 for "restore" multiple times, the nuget.config path is ignored the second time.
E.g.
...
- task: UseDotNet@2
displayName: Use .NET 6 SDK
inputs:
packageType: sdk
version: 6.x
- task: NuGetToolInstaller@1
displayName: 'Use NuGet 6.2'
inputs:
versionSpec: 6.2.*
- task: NuGetAuthenticate@1
- task: DotNetCoreCLI@2
displayName: 'NuGet restore Some Solution'
inputs:
command: 'restore'
projects: '$(Build.SourcesDirectory)\build\elastic_log.sln'
feedsToUse: 'config'
nugetConfigPath: '$(Build.SourcesDirectory)/MyPath1/nuget.config'
noCache: true
- task: CmdLine@2
displayName: 'DEBUG SHOW NUGET CONFIG'
inputs:
script: 'type $(Pipeline.Workspace)\Nuget\tempNuGet_$(Build.BuildID).config'
condition: always()
- task: DotNetCoreCLI@2
displayName: 'NuGet restore Other Solution'
inputs:
command: 'restore'
projects: '$(Build.SourcesDirectory)\build\test.sln'
feedsToUse: 'config'
nugetConfigPath: '$(Build.SourcesDirectory)/MyPath2/nuget.config'
noCache: true
- task: CmdLine@2
displayName: 'DEBUG SHOW NUGET CONFIG 2'
inputs:
script: 'type $(Pipeline.Workspace)\Nuget\tempNuGet_$(Build.BuildID).config'
condition: always()
Example $(Build.SourcesDirectory)/MyPath1/nuget.config
```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="MSAzure" value="https://msazure.pkgs.visualstudio.com/One/_packaging/MY-FEED/nuget/v3/index.json" />
</packageSources>
</configuration>
Example $(Build.SourcesDirectory)/MyPath2/nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="LocalFeed" value="%BUILD_BINARIESDIRECTORY%\RelWithDebInfo\test_nuget" />
<add key="MSAzure" value="https://msazure.pkgs.visualstudio.com/One/_packaging/MY-FEED2/nuget/v3/index.json" />
</packageSources>
</configuration>
Expected:
Each invocation of NuGet restore will use the provided nuget.config.
Actual, the first time it is executed a file is created at $(Pipeline.Workspace)\Nuget\tempNuGet_$(Build.BuildID).config
with the provided config (and then auth keys are added). The second time, the file exists so the nuget.config from nugetConfigPath is ignored (silently).
I looked at the source here and it seems to be due to the behavior of ensureTempConfigCreated()
which uses the existing file even if there is a different config provided