简体   繁体   中英

Azure Devops build not restoring automapper nuget

I am trying to build a .Net project but it doesn't find Automapper v3.3.1. I have the following build steps:

  1. Use NuGet 4.3.0
  2. NuGet restore
  3. Build solution ...

When running step 3 it gives the error:

Error CS0246: The type or namespace name 'AutoMapper' could not be found (are you missing a using directive or an assembly reference?)

In the Nuget Restore step I have the Path to solution, packages.config, or project.json set to the .sln file.

Under Feeds and authentication I checked the option Feeds and in my NuGet.config I left path to NuGet.config empty since I have a global Nuget.config file on the build server under:

C:\\Users\\user\\AppData\\Roaming\\NuGet\\NuGet.config

In this file I have the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>    
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
      <AzureDevOpsFeed>
      <add key="Username" value="MyUsername" />
      <add key="PAT" value="MyPatKey" />
    </AzureDevOpsFeed>
</configuration>

I would assume the build would use the package source https://api.nuget.org/v3/index.json to restore Automapper. Any idea why this is not working?

The solution quoated from

NuGet not restoring packages on build

I had to go into Source Control and delete all of the files in the packages folder (except repositories.config) before NuGet would restore the missing packages. The idea is that you are using package restore rather than checking your packages in to source control. If it sees the packages in source control, it won't download them.

I had same problem. Try to delete nuget packages folder and rebuild the solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM