dotnet / dotnet/macios

Can't ignore many iOS SDK warnings because they don't have warning codes

Open
#13,002 2 comments 1 reaction 0 assignees View on GitHub
bug msbuild
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 12h
Merged PRs (30d)
123

Description

### Steps to Reproduce

1. Create a project that uses the iOS SDK (such as any `dotnet new maui` project)
2. Build it on Windows
3. Even worse, set WarningsAsErrors for the build

### Expected Behavior

No warnings or errors.

### Actual Behavior

You get warnings such as `There is no available connection to the Mac. Task 'VerifyXcodeVersion' will not be executed.`

And worse, with WarningsAsErrors, that warning becomes an error that is un-ignorable.

### Environment

Latest Windows, VS2022, etc.

### Build Logs

Can share MSBuild binlog if needed. Here's the crux of it:

```
Target Name=_VerifyXcodeVersion Project=maui Space-Dash.csproj
VerifyXcodeVersion
Assembly = D:\agent\1\s\bin\dotnet\packs\Microsoft.iOS.Sdk\15.0.101-preview.10.166\tools\msbuild\iOS\..\iOS\Xamarin.iOS.Tasks.dll
Parameters
SessionId = a61f9594282a736859d08d810636b0c54c0cc56e28c090f61cff10915540b1f1
Errors
D:\agent\1\s\bin\dotnet\packs\Microsoft.iOS.Windows.Sdk\15.0.101-preview.10.166\tools\msbuild\iOS\Xamarin.Messaging.Apple.targets(31,3): There is no available connection to the Mac. Task 'VerifyXcodeVersion' will not be executed [D:\agent\1\templatesTest\maui Space-Dash\maui Space-Dash.csproj]
```

![image](https://user-images.githubusercontent.com/202643/137664112-6ff3cf5e-28f0-4d57-90c8-a75a4429b485.png)

## My thoughts

This particular warning comes from here:
https://github.com/xamarin/xamarin-macios/blob/2972e1b715a11dd508023ea5bb71085d4dbf43ce/msbuild/Xamarin.iOS.Tasks/Tasks/VerifyXcodeVersion.cs#L23

And it seems that the various warning messages are _named_ as if they have warning codes, but when the MSBuild Log APIs are called, no warning code is passed in. The tasks always call this overload:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.build.utilities.tasklogginghelper.logwarning?view=msbuild-16-netcore#Microsoft_Build_Utilities_TaskLoggingHelper_LogWarning_System_String_System_Object___

```c#
public void LogWarning (string message, params object[] messageArgs);
```

And I'm guessing that if they call this overload and pass in a `warningCode`, that would make the warning ignoreable:

```c#
public void LogWarning (string subcategory, string warningCode, string helpKeyword, string file, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber, string message, params object[] messageArgs);
```

And I'd be happy to send a PR to try to fix this in at least some cases.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.