dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.75k forks source link

.NET MAUI App build fails when project references Visual Basic netstandard2.0 or net7.0 library #11997

Open rmotta01 opened 1 year ago

rmotta01 commented 1 year ago

Description

Build fails for iOS and Mac when a Maui project references a Visual Basic netstandard2.0 or net7.0 library.

1>------ Build started: Project: MauiBugVbClassLib, Configuration: Debug Any CPU ------ 1>C:\Program Files\dotnet\packs\Microsoft.MacCatalyst.Sdk\15.4.2372\targets\Xamarin.Shared.Sdk.targets(1916,2): error MSB4019: The imported project "C:\Program Files\dotnet\packs\Microsoft.MacCatalyst.Sdk\15.4.2372\tools\msbuild\MacCatalyst\Xamarin.MacCatalyst.VB.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\packs\Microsoft.MacCatalyst.Sdk\15.4.2372\tools\msbuild\MacCatalyst\Xamarin.MacCatalyst.VB.targets" is correct, and that the file exists on disk. 1>Done building project "ClassLibrary1.vbproj" -- FAILED.

1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\targets\Xamarin.Shared.Sdk.targets(1904,2): error MSB4019: The imported project "C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.iOS.VB.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.iOS.VB.targets" is correct, and that the file exists on disk. 1>Done building project "ClassLibrary1.vbproj" -- FAILED.

Steps to Reproduce

Add a reference to a VB netstandard2.0 or net7.0 library. Build.

Link to public reproduction project repository

https://github.com/rmotta01/MauiBugVbClassLib

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

ios 11, maccatalyst 13.1

Did you find any workaround?

No response

Relevant log output

No response

jfversluis commented 1 year ago

Hey there, thanks for this! Good to see a Visual Basic fan! To be honest I'm not sure if this scenario is supported right now.

In either case, this is going deeper than .NET MAUI, so I will move this one to the iOS repository. Probably they will know more about it there. Thanks!

jfversluis commented 1 year ago

This issue was moved to xamarin/xamarin-macios#17017

rolfbjarne commented 1 year ago

Reopening due to: https://github.com/xamarin/xamarin-macios/issues/17017#issuecomment-1348518302

@jfversluis actually I think this is an issue in MAUI, a plain net7.0-ios project with a VB-reference (netstandard2.0) works just fine.

The problem is here:

https://github.com/dotnet/maui/blob/47f8d3ba07661801094578f2d842426ba8a1fed9/.nuspec/Microsoft.Maui.Resizetizer.targets#L252-L265

This will run the GetMauiItems target in all referenced projects, passing TargetFramework=net7.0-ios - effectively overriding the TargetFramework=netstandard2.0 in the vbproj project file. So you're forcing the vbproj to be built as if it were a net7.0-ios project (which doesn't work).

Zhanglirong-Winnie commented 1 year ago

Verified this issue with Visual Studio Enterprise 17.6.0.1575. Can repro on iOS and macOS platform with sample project. MauiBugVbClassLib-master.zip image