Azure pipeline YAML – install project nuget packages

I have a solution containing roughly 100 aps.net projects, one of which is a Selenium test suite. I wish to create an Azure pipeline that installs only the Nuget packages of the Selenium project, and then builds and runs the Selenium tests. When running the VSBUILD step, my pipeline fails, claiming that the project NuGet packages are missing, so seemingly I’m not getting the project packages correctly. I have the following YAML:

    trigger:
    - master
    
    schedules:
      - cron: "0 22 * * *"
        displayName: Daily midnight run
        branches:
          include:
          - feature/*
          - release/*
        always: true
    
    pool:
      vmImage: 'windows-latest'
    
    variables:
      solution: '**/*.sln'
      buildPlatform: 'Any CPU'
      buildConfiguration: 'Release'
    
    steps:
    - task: [email protected]
   
    - task: [email protected]
      displayName: dotnet restore
      inputs:
        command: restore
        projects: '**/**/Nykredit.Feature.Selenium/Nykredit.Feature.Selenium.Test.csproj'
        includeNuGetOrg: true
    
    - task: [email protected]
      displayName: 'Build Selenium Tests'
      inputs:
        solution: '**/**/Nykredit.Feature.Selenium/Nykredit.Feature.Selenium.Test.csproj'
        vsVersion: 16.0
        # platform: '$(BuildPlatform)'
        # configuration: '$(BuildConfiguration)'
    
    
    - task: [email protected]
      inputs:
        command: test
        projects: '**/*/*.csproj'
        arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
    
    - task: [email protected]
      inputs:
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'

I get the following error:

##[error]src\Feature\Nykredit.Feature.Selenium\Nykredit.Feature.Selenium.Test.csproj(73,5): Error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\..\..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props.

Any suggestions as to how to install the packages of Nykredit.Feature.Selenium.Test.csproj only?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

While to cause of the error eludes me, the solution ended up being uninstalling and reinstalling the offending package. Presumably, this corrected some differences in versions in the configurations.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply