microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
228 stars 12 forks source link

[BUG] Using XAML HotReload breaks compilation targeting Android #1247

Closed albyrock87 closed 2 months ago

albyrock87 commented 3 months ago

Describe the Issue

I'm trying to contribute to the MAUI project https://github.com/dotnet/maui this commit While targeting and android device or emulator and pressing F5 to debug this project I get a compilation error.

/Users/<myuser>/github/maui/src/Core/src/Microsoft.VisualStudio.HotReload.MobileTapInitializer/Microsoft.VisualStudio.HotReload.MobileTapInitializer.ModuleInitializerGenerator/HotReloadMobileTapInitializer.g.cs(24,40): error CS0436: The type 'HotReloadMobileTapInitializer' in 'Microsoft.VisualStudio.HotReload.MobileTapInitializer/Microsoft.VisualStudio.HotReload.MobileTapInitializer.ModuleInitializerGenerator/HotReloadMobileTapInitializer.g.cs' conflicts with the imported type 'HotReloadMobileTapInitializer' in 'Microsoft.Maui.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'Microsoft.VisualStudio.HotReload.MobileTapInitializer/Microsoft.VisualStudio.HotReload.MobileTapInitializer.ModuleInitializerGenerator/HotReloadMobileTapInitializer.g.cs'. [/Users/<myuser>/github/maui/src/Core/src/Core.csproj::TargetFramework=net8.0-android]

Notes:

git clean -xdf
dotnet tool restore && dotnet build ./Microsoft.Maui.BuildTasks.slnf

Steps To Reproduce

No response

Expected Behavior

Android application should compile and start with HotReload working.

Environment Information

NET MAUI 1.1.14 (pre-release) C# 2.35.15 (pre-release) C# DevKit v1.8.10 (pre-release) => stable channel releases have the same issue

dotnet 8.0.201

VSCode 1.90 MacOS Sonoma 14.2.1 (Processor M3) | VS Bug 2113775

MartyIX commented 3 months ago

I attempted to run Maui.Controls.Sample project in VS Code on macOS and I get:

/Users/USER/maui/src/Controls/samples/Controls.Sample/Microsoft.VisualStudio.HotReload.MobileTapInitializer/Microsoft.VisualStudio.HotReload.MobileTapInitializer.ModuleInitializerGenerator/HotReloadMobileTapInitializer.g.cs(65,15): error CS0246: The type or namespace name 'Exception' could not be found (are you missing a using directive or an assembly reference?) [/Users/USER/maui/src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj::TargetFramework=net8.0-maccatalyst]
BretJohnson commented 2 months ago

This should be fixed now, in C# extension 2.39 and later, now published to prerelease. If after updating the C# extension (and MAUI DevKit and C# DevKit extensions) to the latest prerelease you still see this problem, please let us know.