dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.66k stars 1.06k forks source link

.net6 WPF Hot Reload not working #29832

Open Trawacho opened 1 year ago

Trawacho commented 1 year ago

Describe the bug

Hot-Reload is not working. Using a net6.0-windows project.

To Reproduce

create a new project: dotnet new wpf start it: dotnet watch changes in MainWindow.xaml file doesn´t shown in open application window. You have to restart the application.

Exceptions (if any)

Further technical details

.NET SDK: Version: 7.0.101 Commit: bb24aafa11

Runtime Environment: OS Name: Windows OS Version: 10.0.19044 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.101\

Host: Version: 7.0.1 Architecture: x64 Commit: 97203d38ba

.NET SDKs installed: 7.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables: Not set

global.json file: Not found

Trawacho commented 1 year ago

updated to the new VS2022 Version 17.4.4. Still the same problem.
Hot-reload is working in VisualStudio only with a new wpf project. "in-app" toolbar appears. Live Visual Tree can be used. Debugging an existing larger project, Hot-Reload is still not working.

Trawacho commented 1 year ago

Found Workaround....
I comment out the option PublishReadyToRun and PublishSingleFile in the .csproj file.

<PropertyGroup>
   <OutputType>WinExe</OutputType>  
   <TargetFramework>net6.0-windows</TargetFramework>  
   <!--<PublishReadyToRun>true</PublishReadyToRun>-->  
   <!--<PublishSingleFile>true</PublishSingleFile>-->  
   <Nullable>disable</Nullable>  
   <UseWPF>true</UseWPF>  
   <SatelliteResourceLanguages>de</SatelliteResourceLanguages>  
   <Version>1.0.7.0</Version>  
</PropertyGroup>

Now the hot reload and LiveVisualTree works as expected

amine-aboufirass commented 4 months ago

Doesn't work for me