Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dotnet-publish output path #549

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions docs/guides/platforms/how-to-use-web-assembly.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,40 @@ cd BrowserTest.Browser
dotnet run

# Output:
# App url: http://localhost:5000/index.html
# App url: https://localhost:5001/index.html
# App url: http://127.0.0.1:53576/
# App url: https://127.0.0.1:53577/
# Debug at url: http://127.0.0.1:53576/_framework/debug
# Debug at url: https://127.0.0.1:53577/_framework/debug
```


### Deployment
In the `BrowserTest.Browser` directory, run:
```bash
dotnet publish

# ... (build output)
# Generated app bundle at .../bin/Release/net8.0/browser-wasm/AppBundle/
```
Now you can serve your app from the `bin/Release/net8.0/browser-wasm/AppBundle` folder (for .NET 8.0, for example) using your favorite web server (such as Azure Static Web Apps).

> **Beware:**
After project was published, .NET SDK creates an app bundle directory with `index.html` file and compiled application files.
With latest .NET 8 SDK, this directory is located at `bin/Release/net8.0-browser/browser-wasm/publish`.
Now you can serve your app from this directory using your favorite web server (such as Azure Static Web Apps).

:::note
On older .NET SDK versions, app bundle was located in different directory: `bin/Release/net8.0-browser/browser-wasm/AppBundle` (search for `AppBundle`).
:::

:::warning
Currently using `dotnet publish` with the `-o` or `--output` flag does not produce the AppBundle folder in the output directory. (See [this issue](https://github.com/dotnet/runtime/issues/94319).) You'll still have to grab it out of the `bin` directory at the path specified by the publish output.
:::

#### Testing AppBundle locally
You can serve your wasm app from the AppBundle directly using the [dotnet-serve](https://github.com/natemcmaster/dotnet-serve) tool as follows:

You can serve your wasm app from this directly using the [dotnet-serve](https://github.com/natemcmaster/dotnet-serve) tool as follows:
```bash
dotnet tool install --global dotnet-serve

dotnet serve -d:bin/Release/net8.0/browser-wasm/AppBundle
dotnet serve -d:bin/Release/net8.0-browser/browser-wasm/publish

# Output:
# Starting server, serving bin/Release/net8.0/browser-wasm/AppBundle
# Starting server, serving bin/Release/net8.0-browser/browser-wasm/publish
# Listening on any IP:
# http://localhost:49875
```
Expand Down