Hi tarun k
As we discussed in private message,
The errors seem like
error NU1101: Unable to find package Microsoft.VisualStudio.Web.CodeGeneration.Design.
error NU1102: Found 100 version(s) in Artifactory [ Nearest version: ... ]
This usually points to missing or misconfigured NuGet sources.
If you are using template-based restore (e.g., netcore-nuget-restore.yml
)
Update the DotNetCoreCLI@2
step to explicitly pass the path to the nuget.config
, ensuring the path exists inside the container:
- task: DotNetCoreCLI@2
displayName: 'Restore Dependencies'
inputs:
command: 'restore'
projects: '**/*.csproj'
restoreArguments: '--no-cache --configfile $(Build.SourcesDirectory)/nuget.config'
Then, in the preceding step, ensure the secure file is copied to that location:
- task: PowerShell@2
displayName: 'Copy nuget.config'
inputs:
targetType: 'inline'
script: |
Copy-Item "$(nuget.secureFilePath)" "$(Build.SourcesDirectory)\nuget.config"
Alternatively, you can Mount nuget.config into the container using a script task
Update your container job to copy the nuget.config into the source folder - main pipeline file that the container sees.
jobs:
- job: TestWithDotNetSdkImage
displayName: 'Run dotnet test in official SDK image'
container:
image: mcr.microsoft.com/dotnet/sdk:8.0
steps:
- checkout: self
# 1. Download nuget.config from Secure Files
- task: DownloadSecureFile@1
name: nuget
displayName: 'Download nuget.config'
inputs:
secureFile: 'nuget.config' # This should match the name in Library > Secure files
# 2. Copy nuget.config into working directory seen by container
- script: |
cp "$(nuget.secureFilePath)" "$(Build.SourcesDirectory)/nuget.config"
displayName: 'Copy nuget.config to container-accessible location'
# 3. Optional: Print file structure for debug
- script: tree $(Build.SourcesDirectory)
displayName: 'Print file tree'
# 4. Restore using nuget.config
- script: |
dotnet restore source/R2T2CoreTests/R2T2CoreTests.csproj --configfile $(Build.SourcesDirectory)/nuget.config
displayName: 'Restore Dependencies'
# 5. Test
- script: |
dotnet test source/R2T2CoreTests/R2T2CoreTests.csproj --configuration Release
displayName: 'Run dotnet test'
Hope this helps!
Please Let me know if you have any queries.