maui: C# Hot Reload Broken in VS 2022 17.2.0 Preview 3

Description

Hot Reload does not work with Windows / Android or IOS. Doesn´t matter if emulator or native device.

I have a clean Windows 11 install (no insider) and VS 2022 17.2.0 Preview 1 installed. If I try to change this

private void OnCounterClicked(object sender, EventArgs e)
{
	count++;
	CounterLabel.Text = $"Current count: {count}";

	SemanticScreenReader.Announce(CounterLabel.Text);
}

to this

private void OnCounterClicked(object sender, EventArgs e)
{
count+=3;
CounterLabel.Text = $"Current count: {count}";

SemanticScreenReader.Announce(CounterLabel.Text);
}

i get this while debugging: image

Hot Reload works fine in Console Apps or ASPNET.

I deinstalled and reinstalled VS 2022 Preview but no effect

Steps to Reproduce

  • dotnet new maui -o mnew3
  • open with 2022 Preview
  • Start debugging (doesn´t matter if Windows / Android / IOS
  • While debugging, change counter++ to counter+=3
  • The strange hot reload error happens

Version with bug

Preview 13 (current)

Last version that worked well

Preview 12

Affected platforms

iOS, Android, Windows

Affected platform versions

IOS 15

Did you find any workaround?

no

Relevant log output

no error in logs

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 13
  • Comments: 22 (3 by maintainers)

Most upvoted comments

Also not working on newly created Blazor Hybrid project with 17.3 P1.1 Only css hot reload works, but if I change html text, or the increment of the counter in the component, nothing updates …

Maybe not related to this issue as there are other issues specifically related to Blazor Hybrid (#2527, #3973, #4474, #6403), but they are all locked now 😦

I’m using the physical device to start and debug the app.

I try maui-blazor demo with 17.3 preview 1, but hot-reload still not working with razor components 😦 . image static content hot-reload works well, but the changes in razor.css doesn’t work. and html changes doesn’t work in razor components as well.

There’s a fix landing in VS 17.3 Preview 1 that will address this.

@drasticactions thanks a lot for the clarification. I hope it gets fixed soon, since people will definitely hit that when maui is GA.

@florianwachs The bug here isn’t a MAUI bug, it’s a Rosyln bug. If you have a multi-targeted project, Rosyln is generating source builds for every platform, for every hot reload change, which is causing Visual Studio to go “Hey, I can’t apply this change, it’s a rude edit, throw an error!”

You can replicate similar behavior if you have a multi-targeted class library with a similar targets file that MAUI uses.

It is, currently, on track to be fixed for VS 17.3 Preview 1, and it might land in an earlier release in 17.2? But again, to be clear, this is not a MAUI bug.

Tested in VS 2022 17.2.0 Preview 3, now the on top mentioned dialog doesn’t pop up, but a dialog telling me it can not perform hotreload and needs to rebuild and restart. I now can check a checkbox that automates this for me, which is indeed better than the situation before. Since MAUI is now considered RC, may I ask if Hot Reload will work on Release next month? I tried it with Blazor MAUI, Maui with Windows / Android target. IOS doesn’t work for me because of Apple API Changes which are tracked by a other bug in the VS Community.

Not sure if related, but I’m having problems with Hot Reload and iOS specifically. Apologies if not related, but didn’t want to create a new bug if it is somehow related to this issue.

See below for error

image