-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
Build failure:
/Users/builder/azdo/_work/1/s/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23414.11/sdk-manifests/8.0.100-rc.1/microsoft.net.workload.mono.toolchain.current/8.0.0-rc.1.23414.4/WorkloadTelemetry.targets(41,27): error MSB4186: Invalid static method invocation syntax: "[System.IO.Path]::GetFileName().ToLower()". Method 'System.IO.Path.GetFileName' not found. Static method invocation should be of the form:
$([FullTypeName]::Method()), e.g. $ ([System.IO.Path]::Combine(a,b)). Check that all parameters are defined, are of the correct type, and are specified in the right order. [/Users/builder/azdo/_work/1/s/xamarin-macios/tests/dotnet/MySimpleApp/MacCatalyst/MySimpleApp.csproj]
Binlog:
log-publish-20230815_052259.binlog.zip
Reproduction Steps
This seems to happen when doing dotnet publish for universal macOS and Mac Catalyst projects.
I'm guessing the reason is that the outer build doesn't do what normal builds do, and the ReferencePath item group is empty:
Lines 41 to 42 in 1eb702c
| <_WorkloadUsesOther Condition="'$([System.IO.Path]::GetFileName(%(ReferencePath.Identity)).ToLower())' == 'avalonia.dll'">true</_WorkloadUsesOther> | |
| <_WorkloadUsesOther Condition="'$([System.IO.Path]::GetFileName(%(ReferencePath.Identity)).ToLower())' == 'uno.dll'">true</_WorkloadUsesOther> |
thus MSBuild failing to find the method "System.IO.Path.GetFileName()" (the method with 0 arguments).
Expected behavior
Successful build.
Actual behavior
Broken build.
Regression?
Yes.
Known Workarounds
No response
Configuration
This happens in our latest dotnet/installer bump: dotnet/macios#18607.
Other information
I'm guess the fix would be to quote the arguments to GetFileName:
<_WorkloadUsesOther Condition="'$([System.IO.Path]::GetFileName('%(ReferencePath.Identity')).ToLower())' == 'avalonia.dll'">true</_WorkloadUsesOther>
<_WorkloadUsesOther Condition="'$([System.IO.Path]::GetFileName('%(ReferencePath.Identity')).ToLower())' == 'uno.dll'">true</_WorkloadUsesOther>So that the method resolution to System.IO.Path.GetFileName looks for the method with a single string parameter, even if %(ReferencePath.Identity) is empty.
(that probably doesn't work as-is, because the new quotes would have to be escaped somehow).
This was probably introduced in #90208.