0

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?

doorman
  • 15,707
  • 22
  • 80
  • 145
  • 1
    Can you check the logs of "Nuget restore". If there is an error while restoring the package than this should be logged there. The package is listed in the packages.config of the project that needs that reference ? – D.J. Mar 26 '19 at 15:15
  • 1
    Are the [permissions](https://learn.microsoft.com/en-us/azure/devops/artifacts/feeds/feed-permissions?view=azure-devops) set correctly? – stuartd Mar 26 '19 at 15:46
  • Hi, I looked at the log for the restore step and it is showing a warning Saving NuGet.config to a temporary config file. ##[warning]No package sources were found in the NuGet.config file at C:\a\_work\2\Nuget\tempNuGet_25545.config – doorman Mar 26 '19 at 15:58
  • Which NuGet.config file is the warning referring to? – doorman Mar 26 '19 at 15:59

2 Answers2

0

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.

doorman
  • 15,707
  • 22
  • 80
  • 145
  • 1
    btw: repositories.config is not needed anymore so the whole packages-folder can be safeley deleted – D.J. Mar 27 '19 at 12:12
-1

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