我想启动我的Blazor应用程序与特定的配置,并有热重加载启用。
当我启动时:
dotnet watch热重装已启用,一切正常。
当我与:
dotnet watch run -c Simulation热重新加载是不活动的,应用程序重建时,一个文件被改变。
我试着用:
dotnet watch -c Simulation但返回的是"watch :带错误代码1退出“。
如何启动我的应用程序?
编辑:
我从launchSettings.json文件中获得的启动配置文件:
"Dotnet Watch": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\dotnet\\dotnet.exe",
"commandLineArgs": "watch run -c $(Configuration)",
"hotReloadProfile": "aspnetcore",
"workingDirectory": "$(ProjectDir)",
"launchUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}添加"hotReloadProfile":"aspnetcore“不起作用。
我的dotnet版本是:
6.0.300-preview.22154.4EDIT2:
临时我使用环境变量而不是项目配置在仿真配置文件和其他配置文件之间切换,但奇怪的是,没有任何解决方案对特定配置文件进行热重加载。网络上什么都没有。
发布于 2022-04-27 12:41:18
根据这篇文章的说法,方法是将"hotReloadProfile": "aspnetcore"添加到launchSettings.json中,如下所示:
{
"profiles": {
"dotnet": {
"commandName": "Project"
}
}
}并使用dotnet watch run命令调试应用程序。
编辑:
从dotnet版本6.0.300-preview.22204.3开始,这个问题已经得到解决,您在第一次编辑时显示的配置可以用于Visual和JetBrains Rider。使用名为Simulation的新虚拟配置在vanila项目上测试,该配置直接从调试中复制。
尽管如此,dotnet cli似乎不能调用此启动配置文件。
PS P:\Path\To\Project> dotnet run --launch-profile "Dotnet Watch"
The launch profile "Dotnet Watch" could not be applied.
The launch profile type 'Executable' is not supported.我的完整launchSettings.json
{
"profiles": {
"HotRelaodTests": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Dotnet Watch": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\dotnet\\dotnet.exe",
"commandLineArgs": "watch run -c $(Configuration)",
"workingDirectory": "$(ProjectDir)",
"launchUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}编辑#2
在阅读了来自@mlhDev的评论之后,我再次尝试了这个配置,使用了.NET 6.0.400 (稳定的,而不是预发布的),热重加载似乎有效。
请参阅GIF PoC
https://stackoverflow.com/questions/72028509
复制相似问题