This project references NuGet package(s) that are missing on this computer. The missing file is ..\packages\NUnit.3.10.1\build\NUnit.props
T

4

16

I am encountering the error during the Build phase of an Azure Pipeline on the Azure DeveOps site. Specifically, the packages it is complaining about are:

2018-09-30T20:35:07.6022998Z
==============================================================================
2018-09-30T20:35:08.4023740Z [command]C:\Windows\system32\chcp.com 65001
2018-09-30T20:35:08.4106228Z Active code page: 65001
2018-09-30T20:35:08.4688610Z [command]"C:\Program Files\dotnet\dotnet.exe" build D:\a\1\s\ClassService.Tests\WebAPITests.csproj --configuration release
2018-09-30T20:35:08.7564734Z Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
2018-09-30T20:35:08.7565155Z Copyright (C) Microsoft Corporation. All rights reserved.
2018-09-30T20:35:08.7565308Z 
2018-09-30T20:35:09.2187455Z   Nothing to do. None of the projects specified contain packages to restore.
2018-09-30T20:35:09.2600797Z D:\a\1\s\ClassService.Tests\WebAPITests.csproj(60,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\NUnit.3.10.1\build\NUnit.props.
2018-09-30T20:35:09.2684158Z 
2018-09-30T20:35:09.2685014Z Build FAILED.
2018-09-30T20:35:09.2685593Z 
2018-09-30T20:35:09.2685883Z D:\a\1\s\ClassService.Tests\WebAPITests.csproj(60,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\NUnit.3.10.1\build\NUnit.props.
2018-09-30T20:35:09.2685950Z     0 Warning(s)
2018-09-30T20:35:09.2686808Z     1 Error(s)
2018-09-30T20:35:09.2686892Z 
2018-09-30T20:35:09.2687550Z Time Elapsed 00:00:00.45
2018-09-30T20:35:09.3022976Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2018-09-30T20:35:09.3036637Z [command]"C:\Program Files\dotnet\dotnet.exe" build D:\a\1\s\DanceWorksStudio.MobileAppService\DanceWorksStudio.MobileAppService.csproj --configuration release

I have looked at similar questions where the solution is to perform a Nuget restore but they usually refer to a local machine or a Visual Studio installation not Visual Studio Team Services (the previous name for Azure DevOps).

In this case, the computer is a Hosted 2017 Agent in the Azure DevOps environment and I don't see how get a Nuget Restore job to execute there.

However, earlier in the log file, I do see references to where the build agent is installing the required Nunit Nuget packages:

2018-09-30T20:34:18.9378894Z        Using "RestoreTask" task from assembly "C:\Program Files\dotnet\sdk\2.1.400\NuGet.Build.Tasks.dll".
2018-09-30T20:34:18.9379005Z        Task "RestoreTask"
2018-09-30T20:34:18.9379127Z          (in) RestoreGraphItems Count '19'
2018-09-30T20:34:18.9379258Z          (in) RestoreDisableParallel 'False'
2018-09-30T20:34:18.9379370Z          (in) RestoreNoCache 'True'
2018-09-30T20:34:18.9379483Z          (in) RestoreIgnoreFailedSources 'False'
2018-09-30T20:34:18.9379610Z          (in) RestoreRecursive 'True'
2018-09-30T20:34:18.9379721Z          (in) RestoreForce 'False'
2018-09-30T20:34:18.9379834Z          (in) HideWarningsAndErrors 'False'
2018-09-30T20:34:19.0149316Z          Running restore with 2 concurrent jobs.    
2018-09-30T20:34:19.0239478Z          Reading project file D:\a\1\s\DanceWorksStudio.MobileAppService\DanceWorksStudio.MobileAppService.csproj.
2018-09-30T20:34:19.0621933Z          Restoring packages for D:\a\1\s\DanceWorksStudio.MobileAppService\DanceWorksStudio.MobileAppService.csproj...


2018-09-30T20:34:20.1980374Z            GET https://api.nuget.org/v3-flatcontainer/nunit/index.json
2018-09-30T20:34:20.2168394Z            GET https://api.nuget.org/v3-flatcontainer/nunit3testadapter/index.json
2018-09-30T20:34:28.8022324Z            GET https://api.nuget.org/v3-flatcontainer/nunit/3.10.1/nunit.3.10.1.nupkg


2018-09-30T20:34:39.7126978Z          Acquiring lock for the installation of NUnit3TestAdapter 3.10.0
2018-09-30T20:34:39.7127033Z          Acquired lock for the installation of NUnit3TestAdapter 3.10.0
2018-09-30T20:34:39.7127104Z          Installing NUnit3TestAdapter 3.10.0.

2018-09-30T20:34:39.7946703Z          Acquiring lock for the installation of NUnit 3.10.1
2018-09-30T20:34:39.7947844Z          Acquiring lock for the installation of Microsoft.AspNetCore.Http.Abstractions 1.0.3
2018-09-30T20:34:39.7950455Z          Acquired lock for the installation of NUnit 3.10.1
2018-09-30T20:34:39.7950672Z          Installing NUnit 3.10.1.

2018-09-30T20:34:43.5285313Z          Completed installation of NUnit3TestAdapter 3.10.0

2018-09-30T20:34:46.7897372Z          Completed installation of NUnit 3.10.1
Tracytrade answered 30/9, 2018 at 21:24 Comment(3)
You need to run dotnet restore command before your build in order to install all the required packageBrushwood
Did you ever find a solution to this? I'm hitting the same issue.Larynx
Any help? met the same tooMatsu
C
28

It's a known Nuget issue

Look here

The solution is, in your test project's .csproj file, at the bottom normally, you'll find a section

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>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 {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.12.0\build\NUnit.props'))" />
  </Target>

Delete that section.

Cumulonimbus answered 18/9, 2019 at 15:31 Comment(2)
I ran into this error today on a brand new project and this fixed it for me, so apparently over a year later this remains an issue.Paralytic
No need to delete entire section; only to "the paths that were pointing to where those two used to be" as Rod answer belowShontashoo
G
4

For what it's worth, I solved the problem by removing the erroneous tags in the Target tag. This is what I initally had in my .csproj file:

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>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 {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
    <Error Condition="!Exists('packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
</Target>

I looked at it and realized that the two lines that had !Exists('packages\EntityFramework.6.4.4... were pointing to where those two used to be, before I moved the project. So, I deleted them. Now I have this:

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>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 {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
    <Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
</Target>

This got rid of the error in Azure DevOps Services Pipeline. It now builds with no errors.

Gare answered 23/12, 2020 at 16:38 Comment(1)
This is the solution; no need to delete entire section; only the entries that "were pointing to where those two used to be"Shontashoo
S
1

Make sure that the "Restore NuGet Packages" Option is checked on your pipeline "Build" step:

enter image description here

Stortz answered 23/4, 2020 at 16:23 Comment(1)
I don't think this is correct. If you click the "i" icon next to the Restore NuGet Packages line, you'll see Microsoft has noted This option is deprecated. To restore NuGet packages, add a NuGet Tool Installer task before the build. This option has no impact.Paralytic
S
0

I had similar issue with NUnit.3.12.0. Build was failing on one machine while working perfectly on another. After a long search, I've realized that I'm missing file NUnit.props in Solution/packages/NUnit.3.12.0/build/. Copying that file from working machine fixed the issue instantly.

Spilt answered 8/2 at 7:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.