Jenkins does not restore NuGet packages with new MSBuild recovery goal

We have a full-featured .net WPF application .net, which we have moved from .net 4.6.2 to 4.7.1 along with changing the PackageReference in the csproj file instead of packages.config.

Building on development machines seems to be fine, and the packages load and recover, but when we build on our Windows Server 2012 build server with Jenkins , the nuget packages do not seem to be restored correctly.

We use MSBuild v15.5 with the last "msbuild / restore" command to restore packages during build. Note: Using the previous method call "NuGet recovery" does the job, but we need to be able to use MSBuild / restoration at the moment .

It seems that the package recovery process looks at the correct NuGet servers and passes the recovery without errors (this is a test solution compiled in Jenkins to identify the problem):

Restore:
  Restoring packages for c:\Jenkins\workspace\Test\ConsoleApp1\ConsoleApp1.csproj...
  Committing restore...
  Generating MSBuild file c:\Jenkins\workspace\Test\ConsoleApp1\obj\ConsoleApp1.csproj.nuget.g.props.
  Generating MSBuild file c:\Jenkins\workspace\Test\ConsoleApp1\obj\ConsoleApp1.csproj.nuget.g.targets.
  Writing lock file to disk. Path: c:\Jenkins\workspace\Test\ConsoleApp1\obj\project.assets.json
  Restore completed in 577.05 ms for c:\Jenkins\workspace\Test\ConsoleApp1\ConsoleApp1.csproj.

  NuGet Config files used:
      c:\Jenkins\workspace\Test\NuGet.Config
      C:\Windows\system32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config

  Feeds used:
      http://devbuild/NuGetHost/nuget
      https://api.nuget.org/v3/index.json
Done Building Project "c:\Jenkins\workspace\Test\ConsoleApp1.sln" (Restore target(s)).

But when msbuild arrives to compile the code, we get the following errors, which look as if NuGet was not loaded:

CSC : error CS0006: Metadata file 'C:\Windows\system32\config\systemprofile\.nuget\packages\log4net\2.0.8\lib\net45-full\log4net.dll' 
could not be found [c:\Jenkins\workspace\Test\ConsoleApp1\ConsoleApp1.csproj]

Any ideas why nuget packages are not being restored?

+13
source
2

NuGet .net !

, NuGet msbuild msbuild, NuGet ( msbuild/restore) Windows Server 2012 , NuGet, - , 32- 64-. , , .

, msbuild , C:\Windows\system32\config\systemprofile\.nuget\packages.

NuGet, NUGET_PACKAGES, , C:\NugetPackageCache, :

NUGET_PACKAGES=C:\NugetPackageCache

Jenkins, Build Environment-> Inject process-> Properties Content :

NUGET_PACKAGES=C:/NugetPackageCache

NuGet, - , msbuild , ..

NUGET_PACKAGES=C:\Windows\system32\config\systemprofile\.nuget\packages

. NuGet. , NuGet, .

. / EnvInject Jenkins, :

Jenkins plugin with environment variables

+25

, .NET Framework, 4.7.2, <PackageReference> packages.config, Jenkins Windows, . , nuget restore nuget MyGet, , , , . " " nuget restore.

mips ( NuGet), , , , C:\Windows\system32\config\systemprofile\AppData\Roaming\NuGet\NuGet.config ( MyGet), C:\Windows\SysWOW64\config\systemprofile\AppData\Roaming\NuGet\NuGet.config. , NuGet.config system32 SysWOW64.

NUGET_PACKAGES.

0

Source: https://habr.com/ru/post/1693888/


All Articles