We have a .net full framework WPF application that we\'ve moved from .net 4.6.2 to 4.7.1 along with changing to PackageReference in the csp
For us it was indeed an issue with bitness!
The problem specifically is that MSBuild is actually looking for the nuget packages in the following directory:
C:\Windows\SysWOW64\config\systemprofile\.nuget\packages
Even though the logs actually say:
C:\Windows\System32\config\systemprofile\.nuget\packages
Because the msbuild being called is a 32-bit process running on a 64-bit platform, when it looks in System32, it's actually looking into SysWOW64.
This is done by file system redirection.
The solution for us was to simply call the 64-bit version of MSBuild, located at:
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe
Notice the amd64 in the path.