dotnet / dotnet/aspnetcore

Еmbed the wwwroot directory and it's contents in order to create a single file executable when using Blazor in WPF

Open
#50,894 7 comments 4 reactions 0 assignees View on GitHub
area-blazor enhancement
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

Generating single-file executable not working in _WPF Blazor_ application, which is an installation inconvenience. Also, this may be considered as a **security vulnerability** if someone changes the JS files inside the _wwwroot_ folder?

In the publish directory, there's a _wwwroot_ folder next to the executable containing static assets:
![image](https://github.com/dotnet/aspnetcore/assets/20843160/7ffc0cee-448f-4a1d-9050-0a775501bcd0)

Not working even if you try to embed everything in _wwwroot_ folder with the following addition to the `.csproj` file, because there are some files generated on build/publish (like the CSS isolation bundling file `{ASSEMBLY NAME}.styles.css`):
```

```

### Expected Behavior

Possibility to publish a WPF Blazor application (or any other BlazorWebView based application) as a single-file.

### Steps To Reproduce

1. [Create WPF Blazor application](https://learn.microsoft.com/en-us/aspnet/core/blazor/hybrid/tutorials/wpf?view=aspnetcore-7.0)
2. Publish the project as single-file using the following command: `dotnet publish -r win-x64 --self-contained true -p:PublishSingleFile=true`

### Exceptions (if any)

_No response_

### .NET Version

7.0.401

### Anything else?

BlazorWebView itself has the ability to load and operate with embedded static files. However, in order for this to work, the wwwroot files should be present before publishing/embedding them. The publishing step would first have to generate the _wwwroot_ files before they could be embedded.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.