Share via


confused on nuget package restore on VS 2017

Question

Monday, April 9, 2018 5:37 PM

Trying to build a piece of sample code from Github and I got the error message of:  

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\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets.

BUT when I look into the folder of:

..\packages\Microsoft.Bcl.Build.1.0.21\build

I do see the file: Microsoft.Bcl.Build.targets.

Thanks in advance for any pointer/suggestion.

All replies (4)

Tuesday, April 10, 2018 3:05 AM

Hi,

Welcome to MSDN forum.

You can use the NuGet command line in the Package Manager Console(Tools > Nuget Package Manager > Package Manager Console):

Update-Package -reinstall

to force reinstall the package references into project.

Besides, you can also have a look at the thread and try solutions in it:

https://stackoverflow.com/questions/32254439/nuget-packages-are-missing

Removing this code from .csproj file:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
  ......
</Target>

Best regards,

Joyce

Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Wednesday, April 11, 2018 6:28 AM

Tx.   Doing the Update-Package -reinstall didn't help.   Same error.

Removing the actual code that generated this very error would obviously do the trick.   Not entirely sure if that's a good idea/practice though.     Is this a well known/common error?

Having said that, I'm a little surprised to see some of these nugets files, including the version numbers, being hardcoded into the build-scripts.   Any particular reasons we do it this way?   This piece of code is originally provided by Microsoft, FYI.


Wednesday, April 11, 2018 9:27 AM

Hi,

Thank you for the update.

>>Removing the actual code that generated this very error would obviously do the trick.   Not entirely sure if that's a good idea/practice though.     Is this a well known/common error?

Starting with Nuget 2.7 and Visual Studio 2013, it’s no longer advised to use the “Enable NuGet Package Restore” feature, now there is “Automatic Package Restore”, which is a feature that allows VS 2013 to automatically download missing packages as part of the build. you need to go through some pains to extricate yourself from “Enable Package Restore” before you can successfully work with “Automatic Package Restore”.

So, you need to remove some lines from .csproj file.

https://chrismay.org/2015/01/07/nuget-switching-from-enable-package-restore-to-automatic-package-restore/

Best regards,

Joyce

Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Tuesday, April 17, 2018 6:56 AM

Hi alecela,

You could get useful information for NuGet Package Restore here:

/en-us/nuget/consume-packages/package-restore

You could disable it here:

But my understanding is that since you changed the project's folder, so you need to re-edit the .xxproj file or others.

https://stackoverflow.com/questions/32254439/nuget-packages-are-missing

Best Regards,

Jack

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].