Skip to content

The executable file is too large after build #11253

@maihcx

Description

@maihcx

Description

I use dotnet publish with SelfContained=false and PublishSingleFile=true options and noticed that when I update to .net10 the file size after build is very large compared to .net9

Reproduction Steps

I use this bat command to build

@echo off
setlocal enabledelayedexpansion
echo ================================
echo   Building TrackingRTF Project
echo ================================

set OUTPUT_DIR=.\publish

REM Danh sách các project cần build (thêm project mới vào đây)
set PROJECTS=TrackingRTF TrackingRTF.FoCRTL TrackingRTF.Tray TrackingRTF.Core

REM Tạo thư mục output nếu chưa có
if not exist "%OUTPUT_DIR%" (
    mkdir "%OUTPUT_DIR%"
)

REM Xóa các file exe cũ
echo Cleaning old executables...
for %%P in (%PROJECTS%) do (
    if exist "%OUTPUT_DIR%\%%P.exe" (
        echo Removing old exe: %%P.exe
        del /q "%OUTPUT_DIR%\%%P.exe"
    )
)

REM Build từng project
echo.
echo Starting build process...
echo.

for %%P in (%PROJECTS%) do (
    echo [%%P] Building...
    
    dotnet publish .\%%P\%%P.csproj -c Release -r win-x64 --self-contained false ^
        /p:PublishSingleFile=true ^
        /p:IncludeAllContentForSelfExtract=true ^
        /p:DebugType=None ^
        /p:DebugSymbols=false ^
        -o "%OUTPUT_DIR%"
    
    if !errorlevel! neq 0 (
        echo [%%P] Build FAILED!
        pause
        exit /b !errorlevel!
    )
    
    echo [%%P] Build successful!
    echo.
)

echo ================================
echo   All builds completed!
echo   Output: %OUTPUT_DIR%
echo ================================
pause

Expected behavior

I wish when building with dotnet publish the file size would be improved similar to .net9. Here is a picture to prove it

Image

Actual behavior

this is after i upgraded to .net10

Image

Regression?

This issue does not occur in .net9 and lower versions

Known Workarounds

My current solution is to downgrade to .net9

Impact

No response

Configuration

  • Net 10
  • Windows 11 | Version 25H2 (OS Build 26200.7171)
  • x64
  • I'm not sure

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions