Share via


Stuck at missing NuGet package from Visual Studio 2017

Question

Tuesday, April 10, 2018 2:57 AM

Hi all!

Trying to build a piece of sample code within VS 2017 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.

Both package restore options within package manager settings are ticked/enabled.

Thanks in advance for any pointer/suggestion.

All replies (2)

Wednesday, April 11, 2018 5:48 AM | 2 votes

Hi alecela,

Welcome to the MSDN forum.

Refer to the error message, please have a look at this similar issue. Backup the whole solution, then right click the project name in the VS and choose ‘Unload Project’, check this nuget package ‘Microsoft.Bcl.Build’ path is correct and existing on your computer or remove the following code from the .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\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props'))" />

    <Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />

    <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />

  </Target>

If the relative path is right and you can also right click the project name, select ‘Manage Nuget Packages…’ to uninstall this package ‘Microsoft.Bcl.Build’, then manually delete the installation folder like ..\packages\Microsoft.Bcl.Build.1.0.21, then back and re-install this package again.

Best regards,

Sara

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]


Wednesday, December 11, 2019 4:24 PM

AWESOME!!! THIS WORKS! TRIED IN 2019! 

Trying to compile a project i made in 2017, inside of visual studio 2019 and this trick fixed it
THANK YOU SARA!!!!