visual studio build failed nuget package restore not working

Wang, Jesse 0 Reputation points
2025-02-05T18:44:06.03+00:00

load an old vs 2015 project into VS 2022 but failed to build it with following error:
Severity Code Description Project File Line Suppression State

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.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props. SCCMAdminPortal C:\Users\wangja\prj\SCCMAdminPortal\SCCMAdminPortal.csproj 312

Developer technologies Visual Studio Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2025-02-06T02:45:24.7866667+00:00

    Hi @Wang, Jesse, 

    Welcome to Microsoft Q&A! 

    Are you using packages.config or PackageReference format? 

    When using the PackageReference management format, this error might be a leftover from a packages.config to PackageReference migration and needs to be manually removed from the project file.

    When using packages.config, the error means that the package is not installed in the packages folder at the solution root. 

    If NuGet Package Restore doesn’t work, please delete the packages folder (when using packages.config) or the obj/project.assets.json file (when using PackageReference) and run restore again. If the error still persists, use nuget locals all -clear or dotnet nuget locals all --clear from the command line to clear the global-packages and cache folders. 

    Besides, you can backup and remove the following EnsureNuGetPackageBuildImports section from your .csproj file, then rebuild your project:

    <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    ---
    </Target>
    

     

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

     

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.