Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing Nuget.targets

I'm net with C# and Visual Studio 2017. It seems that VS says that Nuget packages are missing. When I'm trying to build the solution the console outputs the following:

"This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is D:\xxxx\xxxx\Desktop\Koodipohjaa\trunk\.nuget\NuGet.targets"

The project is copied from the original location to the desktop (because reasons). In /trunk/ I have a folder called "packages" but no ".nuget" folder. I've tried the "restore nuget packages" from the solution level and it says that there is nothing to update. When I open the references from the project, there is this very cute little yellow triangle with all the packages.

I've tried to update packages, remove them all and reinstalling them automatically etc. In "nuget package manager" I have tried all possible in package restore.


1 Answers

Please try:

1.In VS2017,go Tools menu=>Nuget Package Manager=>Package Manager settings, make sure you've checked these two options like this:

enter image description here

2.Right-click the project in Solution Explorer=>Unload Project=> Right-click the project name and Edit the xx.csproj, you will find a EnsureNuGetPackageBuildImports target in this format:

<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\xxx')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xxx'))" />
  </Target>

Delete the target and save files. Then right-click the project to reload the project and run a rebuild.

I assume you may have such target in your project file(xx.csproj), which tries to find the nuget.targets file, delete the target to check if it helps. Similar issue see here.

like image 187
LoLance Avatar answered Mar 23 '26 14:03

LoLance



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!