Al2110
Al2110

Reputation: 576

References to NuGet packages that are missing. Package Restore or re-installing packages does not work

In a Visual Studio solution, there are several projects, which should have the MSTest.TestAdapter NuGet package, among others. Upon downloading it from source control, each project in the solution shows an error: "This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them."

I have tried using NuGet Package Manager to uninstall and reinstall the affected package, to no avail. I have also tried "package restore".

Each project in the solution contains a packages.config file, with the following contents:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net461" />
  <package id="NLog" version="4.7.7" targetFramework="net461" />
</packages>

Using Visual Studio 2017.

How to fix this?

Upvotes: 0

Views: 720

Answers (1)

Mr Qian
Mr Qian

Reputation: 23848

Enter the csproj file and then delete these two lines:

<Error Condition="!Exists('xxx\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', 'xx\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('xx\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', 'xx\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" />

The two lines are still based on your source control rather than your new VS Environment. You should remove the old wrong path and then install the new path based on your current VS Environment.

After that, enter Tools-->Nuget Package Manager-->Package Manager Console and then type this to reinstall all the nuget packages:

update-package -reinstall

Upvotes: -1

Related Questions