Running dotnet publish fails on Blazor WebAssembly hosted project when using PublishSingleFile=true
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Describe the bug
When I run the `dotnet publish` command on the **server** project of a Blazor WebAssembly hosted application using the following command:
```bash
dotnet publish Server/Server.csproj --configuration Release --output ./publish --runtime linux-x64 -p:PublishSingleFile=true --self-contained true
```
The publish process fails with this error:
```shell
error NETSDK1098: Applications published to a single-file are required to use the application host. You must either set PublishSingleFile to false or set UseAppHost to true.
```
But I'm publishing **only the server project**, and it works fine using Visual Studio using the same settings (e.g., publish profile with `self-contained` and `single-file`).
It seems the `dotnet publish` command recursively tries to publish the Blazor WebAssembly client project with the same settings, even though it's not valid for it (since WASM cannot be single-file).
### To Reproduce
1. Create Blazor Webassembly **hosted** app
2. Run the CLI publish from the Server folder:
```
dotnet publish Server/Server.csproj --configuration Release --output ./publish --runtime linux-x64 -p:PublishSingleFile=true --self-contained true
```
### Expected behavior
The CLI should behave the same as Visual Studio:
- The PublishSingleFile and other settings should apply only to the server project.
- The client project should use its defaults unless explicitly configured.
### Workaround
If I set up a **publish profile** in the server project and reference it in the CLI like this:
```
dotnet publish Server/Server.csproj --configuration Release --output ./publish --runtime linux-x64 --property:PublishProfile=FolderProfile
```
...then publishing **succeeds**, because:
- The server project uses settings from the profile (e.g., `PublishSingleFile=true`, `SelfContained=true`).
- The client project does **not** find this profile, so it falls back to defaults.
### Expectations
`dotnet publish` should support publishing the server project from the CLI in the same way as when using Visual Studio with a publish profile:
- The CLI should **not propagate server-specific settings** like `PublishSingleFile` or `RuntimeIdentifier` to the Blazor client project unless explicitly defined there.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.