Skip to content

Why packed xll is smaller than dll with PublishSingleFile #798

@PaleNeutron

Description

@PaleNeutron

Here is my output dir:

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         2025/9/19     15:27                publish
-a----         2025/9/19     15:27            311 AmWPSAddin.dna
-a----         2025/9/19     15:27         733184 AmWPSAddin.xll                  
-a----         2025/9/19     15:27            311 AmWPSAddin64.dna
-a----         2025/9/19     15:27         658944 AmWPSAddin64.xll  <------ Much smaller
-a----         2025/9/19     15:27        2502656 AmWPSAddinXll.dll  <------- Much bigger
-a----         2025/9/19     15:27         441256 AmWPSAddinXll.pdb
-a----         2024/5/21     15:07          26112 GraphQL.Client.Abstractions.dll
-a----         2024/5/21     15:07          19456 GraphQL.Client.Abstractions.Websocket.dll
-a----         2024/5/21     15:07          82432 GraphQL.Client.dll
-a----         2024/5/21     15:07          22016 GraphQL.Client.Serializer.Newtonsoft.dll
-a----         2024/5/21     15:06          24576 GraphQL.Primitives.dll
-a----         2025/9/16     16:04         721320 Newtonsoft.Json.dll
-a----         2025/5/19      5:22         164864 Serilog.dll
-a----         2025/4/28      8:38          38912 Serilog.Sinks.File.dll
-a----         2020/2/19     18:05          20856 System.Buffers.dll
-a----         2024/3/20      3:38         189104 System.Diagnostics.DiagnosticSource.dll
-a----          2022/5/8     11:31         142240 System.Memory.dll
-a----         2018/10/5     10:36          72192 System.Net.WebSockets.Client.Managed.dll
-a----         2018/5/15     21:29         115856 System.Numerics.Vectors.dll
-a----         2023/5/19     13:42        1358928 System.Reactive.dll
-a----        2021/10/23      7:40          18024 System.Runtime.CompilerServices.Unsafe.dll
-a----        2023/10/31     23:09          74000 System.Threading.Channels.dll
-a----         2020/2/19     18:05          25984 System.Threading.Tasks.Extensions.dll

I tried to use dotnet PublishSingleFile feature to contains all depends lib in one dll and than pack it into xll. But I found that it seems compiled in incorrect order

  1. generate small dll
  2. exceldna pack a small xll
  3. dotnet generate a big dll

Here is my project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <UseWindowsForms>true</UseWindowsForms>
    <PublishSingleFile>true</PublishSingleFile>
    <SelfContained>false</SelfContained>
    <LangVersion>10.0</LangVersion>
  </PropertyGroup>

  <PropertyGroup>
    <ExcelAddInFileName>AmWPSAddin</ExcelAddInFileName>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="ExcelDna.AddIn" Version="1.9.0" />
    <PackageReference Include="ExcelDna.Integration" Version="1.9.0" />
    <PackageReference Include="ExcelDna.Interop" Version="15.0.1" />
    <PackageReference Include="GraphQL.Client" Version="6.1.0" />
    <PackageReference Include="GraphQL.Client.Serializer.Newtonsoft" Version="6.1.0" />
    <PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
    <PackageReference Include="Serilog" Version="4.3.0" />
    <PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
    <PackageReference Include="System.Net.Http" Version="4.3.4" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Include="data_dict/*.json" />
  </ItemGroup>
</Project>

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