msbuild: Unexpected warning/error MSB3202

Attachment

ProjectNotFound.zip

Visual Studio Version

Visual Studio 2022 (17.7.6)

Summary

  • Building project, unexpected warning message: ..\Microsoft.Common.CurrentVersion.targets(1797,5): warning MSB3202: The project file "xxx.csproj" was not found.
  • In more large and complex solution, randomly showing the same MSB3202 message but as error and failed to build

Steps to Reproduce

  1. Open the solution in attachment file
  2. Build the CompanyName.OrganizationName.PackageName.Hardware project
  3. Open and save Class1.cs in the project
  4. Build the project again
  5. Repeat steps 3 to 4, warning MSB3202 is shown in the output window
Build started...
1>------ Build started: Project: CompanyName.OrganizationName.PackageName.Hardware, Configuration: Debug Any CPU ------
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\arm64\Microsoft.Common.CurrentVersion.targets(1797,5): warning MSB3202: The project file "..\..\OtherCompanyName.OrganizationName.PackageName\Network\OtherCompanyName.OrganizationName.PackageName.Network.Connection\OtherCompanyName.OrganizationName.PackageName.Network.Connection.csproj" was not found.
1>Done building project "CompanyName.OrganizationName.PackageName.Network.Communication.IO.csproj".
1>CompanyName.OrganizationName.PackageName.Hardware -> C:\ProjectNotFound\CompanyName.OrganizationName.PackageName\CompanyName.OrganizationName.PackageName.Hardware\bin\Debug\net7.0\CompanyName.OrganizationName.PackageName.Hardware.dll
========== Build: 1 succeeded, 0 failed, 4 up-to-date, 0 skipped ==========
========== Build started at 7:57 PM and took 01.367 seconds ==========

Expected Behavior

  • Build succeeded without any warning/error MSB3202 message because project file(s) does exist

Actual Behavior

  • Unexpected warning/error MSB3202

User Impact

  • Failed to build if error MSB3202 is shown

Notes

  1. This problem can be found in Visual Studio 2019 also
  2. If we use dotnet build or msbuild command to build the project with the same steps, no warning/error MS3202 is shown
  3. If we set Maximum number of parallel project builds to 1, no warning/error MS3202 is shown in Visual Studio
  4. If we disable BuildInParallel in CompanyName.OrganizationName.PackageName.Hardware project, no warning/error MS3202 is shown in Visual Studio
  5. If we unchecked Don't call MSBuild if a project appears to be up to date, no warning/error MS3202 is shown in Visual Studio
  6. If we enable DisableFastUpToDateCheck in CompanyName.OrganizationName.PackageName.Network.Builder and CompanyName.OrganizationName.PackageName.Network.Communication.IO projects, no warning/error MS3202 is shown in Visual Studio
  7. This issue seems to be related to long path issue
  8. Set LongPathsEnabled = 1 in registry does not help

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (9 by maintainers)

Most upvoted comments

@drewnoakes @melytc any further thoughts or updates here? Been running into the same thing.

I think I found it. There is a check for file existence: https://github.com/dotnet/msbuild/blob/7cf66090a764f0f239671e4877255efe7ba91155/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/MSBuild.cs#L343

… and this abstraction calls https://github.com/dotnet/msbuild/blob/7cf66090a764f0f239671e4877255efe7ba91155/src/Framework/NativeMethods.cs#L1837

… which returns false. System.IO.File.Exists returns true for the same path. If we will get rid of this P/Invoke (https://github.com/dotnet/msbuild/pull/9223#issuecomment-2217451762) then it should resolve this issue.

It still doesn’t explain why is this happening on MacOS. I guess it’s a different issue, because the FileExistsWindows is Windows only implementation 😃

I tried to repro by using Archie’s solution, and I can confirm it’s reproable (pretty consistently) on VS 17.10.5. I see warnings in Output Window, but not in Error List. If it’s really reproable also with Rider on MacOS, it could be some weird MSBuild issue. I will assign myself for further investigation, but as this issue is not blocking, I will probably get to it in September (earliest).

There’s enough signal that this isn’t VS-specific, so I’m going to move this to MSBuild for further investigation.

@drewnoakes Can you please provide a link to the issue under MSBuild so those of us interested can follow it?