It looks like I am being forced to chose between the two (either "watch file changes mode" or "attach to Visual Studio mode").
These are the two different "profiles" in launchSettings.json
, and I have to chose one or the other:
"profiles": {
...
"Watch file changes": {
"executablePath": "dotnet.exe",
"workingDirectory": "$(ProjectDir)",
"commandLineArgs": "watch run debug",
"launchBrowser": true,
"applicationUrl": "http://localhost:5000/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Attach to VS": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
It is less than ideal that I have to pick one, I would like to be able to apply a breakpoint ("Attach to VS" mode) and also watch file changes.
BTW, for those interested: the profile "Watch file changes" must be coordinated with the following addition to your .csproj file:
<ItemGroup>
<!-- Files that the "dotnet watch" will monitor for hot reloading: -->
<Watch Include="**\*.razor" />
<Watch Include="**\*.scss" />
<Watch Include="**\*.cshtml"/>
<Watch Include="**\*.cs" />
</ItemGroup>
You can read static or local files by creating HttpClient Get calls. The GetStringAsync method sends a request to the specific URI and returns the response body as a string in an async operation. Please refer to “HttpClient Class” for more details.
In vscode explorer click Open Folder and select project directory. Blazor project template contains some default files, if we run our application right away it will be launched as a Hello World!
Ahead-of-time (AOT) compilation. Blazor WebAssembly supports ahead-of-time (AOT) compilation, where you can compile your . NET code directly into WebAssembly. AOT compilation results in runtime performance improvements at the expense of a larger app size.
Blazor code can now browse local file systems and open up local files and edit them in native Windows apps. With . NET 6 and the latest Visual Studio 2022 preview, developers can create a hybrid Blazor/.
I am able to debug (breakpoint, step by step, inspect variable) my Blazor Webassembly (Blazor WASM) in Visual Studio 2019. And whenever I save certain files (*.razor, *.razor.cs, *.css), dotnet
will automatically rebuild the project then Chrome will automatically refresh the page. Here's what I did:
dotnet watch run
. This will open a new Chrome tab.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With