My solution to this problem was to make the VS files on my C drive.
My setup was I had a reference to an folder on Google Drive. Worked for several days no problems.
But then I got the msb4018 error. Tried to run VS2022 as administrator. Tried a lot of thins. Nothing worked.
When moving my files to my own c crive. The error disappeared :-)