Restore task is failing in the container agent

tarun k 425 Reputation points
2025-06-25T13:33:15.7333333+00:00

I am seeing following error ##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1

Azure DevOps
{count} votes

Accepted answer
  1. Durga Reshma Malthi 6,130 Reputation points Microsoft External Staff Moderator
    2025-06-25T13:54:22.5533333+00:00

    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.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. tarun k 425 Reputation points
    2025-07-01T08:26:07.46+00:00

    After disabling nuget.org in nuget config file it worked

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.