dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.19k stars 1.35k forks source link

[Bug]: MSBuild randomly(?) fails to expand globs #9606

Open alexrp opened 6 months ago

alexrp commented 6 months ago

Issue Description

I have a custom MSBuild SDK that builds Zig/C/C++ projects. The 'test suite' consisting of sample projects randomly fails to build on my machine because MSBuild sometimes fails to expand globs for no apparent reason.

Steps to Reproduce

$ git clone https://github.com/vezel-dev/zig-sdk.git
$ cd zig-sdk
$ ./cake # In a Bash shell.

Expected Behavior

Successful build.

Actual Behavior

Errors of the general form:

  cxxexe failed with errors (26,6s)
    **/*.cxx(1,1): error G91F73F44: unable to build C object: Unexpected

This is the Zig compiler complaining that it's being passed the literal argument **/*.cxx, i.e. MSBuild has failed to expand the glob here: https://github.com/vezel-dev/zig-sdk/blob/6a48e6c8821810ba8053b91419a45ff7bfb8e41f/src/sdk/build/Vezel.Zig.Sdk.Build.props#L20-L22

Analysis

There doesn't appear to be any particular pattern to when it happens.

Versions & Configurations

.NET SDK 8.0.100 MSBuild 17.8.3.51904

rainersigwald commented 6 months ago

This can happen if there are I/O errors during the directory walk, because of #406. A binlog of a failure would be interesting to look at--do you have or can you get one?

alexrp commented 6 months ago

I definitely can. Is there anything in particular I should look for to find such I/O exceptions in the binlog?

alexrp commented 6 months ago

Here's a binlog of a failure in src/samples/cxxexe: binlog

FWIW, I checked the project directory and nothing in there comes even close to MAX_PATH - highest I could find was ~120 characters for the full path.

Is there some kind of switch to turn on logging for globbing failures?

rainersigwald commented 6 months ago

Yeah, nothing's jumping out at me, either :-/

Is there some kind of switch to turn on logging for globbing failures?

There is not, but we should log them. #9609. I think for now you might need a debugger attached, or maybe a procmon trace would have something useful?

alexrp commented 6 months ago

Just for the record, I don't think I've seen the glob failure happen outside of Windows. :thinking:

alexrp commented 5 months ago

Just for the record, I don't think I've seen the glob failure happen outside of Windows. 🤔

Ok, I take that back. I saw it on Linux today.

AR-May commented 5 months ago

Team triage: We are hoping to have this additional logging, without it we are unable to help.

alexrp commented 4 months ago

Seems like https://github.com/dotnet/msbuild/labels/needs-more-info should be removed and this should be marked as blocked on #9609?