novotnyllc / MSBuildSdkExtras

Extra properties for MSBuild SDK projects
MIT License
348 stars 42 forks source link

MSBuild.Sdk.Extras cannot build the TargetFrameworks Xamarin.iOS and net6.0-ios together #291

Open VincentUhlmann opened 2 years ago

VincentUhlmann commented 2 years ago

Issue Description

A Binding Project for iOS based on MSBuild.Sdk.Extras.3.0.44 with the TargetFrameworks Xamarin.iOS and net6.0-ios throws the following error under Visual Studio 2022 for Mac when building: "If you are building projects that require targets from full MSBuild or MSBuildFrameworkToolsPath, you need to use desktop msbuild ('msbuild.exe') instead of 'dotnet build' or 'dotnet msbuild".

I also noticed that if I remove one of the target frameworks ( Xamarin.iOS / net6.0-ios) and change nothing else, the build works.

A Binding Project for Android based on MSBuild.Sdk.Extras.3.0.44 with the TargetFrameworks MonoAndroid and net6.0-android works fine under Windows in Visual Studio 2022. I'm not sure if this is a bug or the Visual Studio 2022 for Mac version just isn't ready yet. However, I can't find a way to build a Binding Project for these TargetFrameworks at the moment. But this is mandatory to make a plugin compatible between Xamarin and Maui.

Steps to Reproduce

Create a Binding Project in Visual Studio 2022 for Mac and set the TargetFrameworks Xamarin.iOS and net6.0-ios and specify the Project SDK to MSBuild.Sdk.Extras.3.0.44.

Try to build this.

Expected Behavior

The build works without error.

Actual Behavior

Error: If you are building projects that require targets from full MSBuild or MSBuildFrameworkToolsPath, you need to use desktop msbuild ('msbuild.exe') instead of 'dotnet build' or 'dotnet msbuild.

m-sadegh-sh commented 2 years ago

I'm getting the same error and found no way to get my machine into the previous working state. I've recently updated Visual Studio for Mac and since then, the build process is broken.

m-sadegh-sh commented 2 years ago

@VincentUhlmann Have you tried to enable MSBuild on macOS? This has fixed my issue!

VincentUhlmann commented 2 years ago

@m-sadegh-sh Yes, one of my first steps was to enable MSBuild on Mac. However, the error remains the same whether I build in VS or in the console.

nirinchev commented 1 year ago

Did you folks come up with a workaround for this? We're in a similar position, trying to multitarget a project for Maui and Xamarin.iOS and are hitting this error.

VincentUhlmann commented 1 year ago

@nirinchev Create two projects in the same solution: Foo.Maui, Foo.Xamarin that pointing to the same files. Only TargetFramework etc. are different then.

nirinchev commented 1 year ago

@VincentUhlmann thank you! I was hoping for something cleaner than that, but I guess there's not much that can be done.