dotnet / dotnet/sdk

Visual Studio Publish produces much smaller framework-dependent single-file exe than dotnet publish with identical settings

Open
#52,298 3 comments 1 reaction 0 assignees View on GitHub
Area-WebSDK untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

I’m seeing a significant difference in output size between Visual Studio Publish (GUI) and `dotnet publish` (CLI), even when using what appear to be identical settings.

Project:
- .NET console application
- Target Framework: net10.0
- OS: Windows (win-x64)

Visual Studio Publish settings:
- Configuration: Release
- Deployment mode: Framework-dependent
- Target runtime: win-x64
- Produce single file: enabled
- Enable ReadyToRun: enabled

Result:
- Visual Studio produces a single executable of ~200 KB
- The app runs correctly and requires the .NET runtime to be installed

CLI / PowerShell command:
```
dotnet publish SpotifyUpdateBlocker.csproj `
-c Release `
-r win-x64 `
--self-contained false `
/p:PublishSingleFile=true `
/p:PublishReadyToRun=true `
/p:TargetFramework=net10.0
```
Result:
- The generated single-file executable is ~80 MB

Question:
Why does Visual Studio Publish produce a much smaller framework-dependent single-file executable than the CLI, even with the same visible options enabled?

Is Visual Studio applying additional internal MSBuild properties or a different publish pipeline that is not accessible via `dotnet publish`?

If so:
- Is this behavior documented anywhere?
- Is there a supported way to reproduce the Visual Studio publish output from the CLI (for CI / automation scenarios)?

At the moment it seems impossible to achieve identical output size and behavior outside of Visual Studio, which makes builds non-reproducible between GUI and CLI.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with SpotifyUpdateBlocker.csproj and reproduce both the Visual Studio Publish and the shown dotnet publish command for net10.0 and win-x64. Compare the generated publish properties and artifacts; done means explaining the size difference and documenting a supported CLI or CI-equivalent configuration, if one exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.