Bug #109670 Many MSB3246 errors when referencing MySql.Data 8.0.32
Submitted: 18 Jan 6:37 Modified: 18 Jan 7:30
Reporter: Bradley Grainger (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.0.32 OS:Windows (10, 11)
Assigned to: CPU Architecture:Other (x64)

[18 Jan 6:37] Bradley Grainger
Description:
When compiling a program that references MySql.Data v8.0.32, dotnet build produces a lot of MSB3246 build warnings. This did not occur with v8.0.31.

The build warnings are:

❯ dotnet build
MSBuild version 17.4.1+9a89d02ff for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. System.BadImageFormatException: PE image does not have metadata. [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at System.Reflection.Metadata.MetadataReader.GetAssemblyName(String assemblyFile) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Shared.AssemblyNameExtension.GetAssemblyNameEx(String path) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Tasks.SystemState.GetAssemblyName(String path) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Tasks.ReferenceTable.SetPrimaryAssemblyReferenceItem(ITaskItem referenceAssemblyName) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. System.BadImageFormatException: PE image does not have metadata. [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at System.Reflection.Metadata.MetadataReader.GetAssemblyName(String assemblyFile) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Shared.AssemblyNameExtension.GetAssemblyNameEx(String path) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Tasks.SystemState.GetAssemblyName(String path) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Tasks.ReferenceTable.SetPrimaryAssemblyReferenceItem(ITaskItem referenceAssemblyName) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. System.BadImageFormatException: PE image does not have metadata. [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at System.Reflection.Metadata.MetadataReader.GetAssemblyName(String assemblyFile) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Shared.AssemblyNameExtension.GetAssemblyNameEx(String path) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Tasks.SystemState.GetAssemblyName(String path) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Tasks.ReferenceTable.SetPrimaryAssemblyReferenceItem(ITaskItem referenceAssemblyName) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. System.BadImageFormatException: PE image does not have metadata. [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at System.Reflection.Metadata.MetadataReader.GetAssemblyName(String assemblyFile) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Shared.AssemblyNameExtension.GetAssemblyNameEx(String path) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Tasks.SystemState.GetAssemblyName(String path) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Tasks.ReferenceTable.SetPrimaryAssemblyReferenceItem(ITaskItem referenceAssemblyName) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. System.BadImageFormatException: PE image does not have metadata. [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at System.Reflection.Metadata.MetadataReader.GetAssemblyName(String assemblyFile) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Shared.AssemblyNameExtension.GetAssemblyNameEx(String path) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Tasks.SystemState.GetAssemblyName(String path) [C:\Code\MySql\Test\Test.csproj]
C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(2352,5): warning MSB3246:    at Microsoft.Build.Tasks.ReferenceTable.SetPrimaryAssemblyReferenceItem(ITaskItem referenceAssemblyName) [C:\Code\MySql\Test\Test.csproj]
  Test -> C:\Code\MySql\Test\bin\Debug\net7.0\Test.dll

Build succeeded.

    5 Warning(s)
    0 Error(s)

How to repeat:
Install .NET SDK v7.0.102.
Run: dotnet new console
Run: dotnet add package MySql.Data
Run: dotnet build

Suggested fix:
Expected 0 warnings, 0 errors, as happened when using MySql.Data 8.0.31:

❯ dotnet build
MSBuild version 17.4.1+9a89d02ff for .NET
  Determining projects to restore...
  Restored C:\Code\MySql\Test\Test.csproj (in 291 ms).
  Test -> C:\Code\MySql\Test\bin\Debug\net7.0\Test.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)
[18 Jan 7:30] MySQL Verification Team
Hello Bradley,

Thank you for the report and feedback.
Verified as described.

regards,
Umesh
[30 Jan 9:26] Rob Janssen
See https://bugs.mysql.com/bug.php?id=109716