Here's a project file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CognitiveServices.Speech" Version="1.26.0" />
<PackageReference Include="SkiaSharp" Version="2.88.3" />
<PackageReference Include="SQLite" Version="3.13.0" />
<PackageReference Include="System.Data.Odbc" Version="7.0.0" />
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
</ItemGroup>
</Project>
The app itself has no code in it.
These packages were intentionally chosen to dramatically demonstrate the difference between RID-specific and portable apps. There is nothing wrong with these packages. The only question is how you use them.
We'll publish the app in two different ways and look at various size metrics.
You'll see that the app is about 11MB and includes 18 files (19 minus 1 for the directory). The size comes from the linux-x64
implementations of the dependencies.
$ dotnet publish --use-current-runtime --self-contained false -c Release
MSBuild version 17.4.1+9a89d02ff for .NET
Determining projects to restore...
Restored /home/rich/app/app.csproj (in 247 ms).
app -> /home/rich/app/bin/Release/net7.0/linux-x64/app.dll
app -> /home/rich/app/bin/Release/net7.0/linux-x64/publish/
$ du -s bin/Release/net7.0/linux-x64/publish/
10924 bin/Release/net7.0/linux-x64/publish/
$ find bin/Release/net7.0/linux-x64/publish/ | wc -l
19
$ find bin/Release/net7.0/linux-x64/publish/ | grep runtimes
$ find bin/Release/net7.0/linux-x64/publish/
bin/Release/net7.0/linux-x64/publish/
bin/Release/net7.0/linux-x64/publish/libMicrosoft.CognitiveServices.Speech.core.so
bin/Release/net7.0/linux-x64/publish/app.runtimeconfig.json
bin/Release/net7.0/linux-x64/publish/libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so
bin/Release/net7.0/linux-x64/publish/System.IO.Ports.dll
bin/Release/net7.0/linux-x64/publish/libsqlite3.so
bin/Release/net7.0/linux-x64/publish/libMicrosoft.CognitiveServices.Speech.extension.mas.so
bin/Release/net7.0/linux-x64/publish/libSystem.IO.Ports.Native.so
bin/Release/net7.0/linux-x64/publish/libMicrosoft.CognitiveServices.Speech.extension.kws.ort.so
bin/Release/net7.0/linux-x64/publish/app.dll
bin/Release/net7.0/linux-x64/publish/libMicrosoft.CognitiveServices.Speech.extension.lu.so
bin/Release/net7.0/linux-x64/publish/app.pdb
bin/Release/net7.0/linux-x64/publish/libMicrosoft.CognitiveServices.Speech.extension.kws.so
bin/Release/net7.0/linux-x64/publish/app
bin/Release/net7.0/linux-x64/publish/Microsoft.CognitiveServices.Speech.csharp.dll
bin/Release/net7.0/linux-x64/publish/libMicrosoft.CognitiveServices.Speech.extension.codec.so
bin/Release/net7.0/linux-x64/publish/System.Data.Odbc.dll
bin/Release/net7.0/linux-x64/publish/SkiaSharp.dll
bin/Release/net7.0/linux-x64/publish/app.deps.json
You'll see that the app is much larger, about twenty times the size across 10 times the number of files. Portable apps offer an interesting scenario, but it would be better as opt-in.
$ dotnet publish
MSBuild version 17.4.1+9a89d02ff for .NET
Determining projects to restore...
Restored /home/rich/app/app.csproj (in 204 ms).
app -> /home/rich/app/bin/Debug/net7.0/app.dll
app -> /home/rich/app/bin/Debug/net7.0/publish/
$ du -s bin/Debug/net7.0/publish/
244092 bin/Debug/net7.0/publish/
$ find bin/Debug/net7.0/publish/ | wc -l
202
$ find bin/Debug/net7.0/publish/ | grep runtimes | wc -l
192
$ find bin/Debug/net7.0/publish/
bin/Debug/net7.0/publish/
bin/Debug/net7.0/publish/app.runtimeconfig.json
bin/Debug/net7.0/publish/System.IO.Ports.dll
bin/Debug/net7.0/publish/app.dll
bin/Debug/net7.0/publish/app.pdb
bin/Debug/net7.0/publish/app
bin/Debug/net7.0/publish/Microsoft.CognitiveServices.Speech.csharp.dll
bin/Debug/net7.0/publish/runtimes
bin/Debug/net7.0/publish/runtimes/win7-x86
bin/Debug/net7.0/publish/runtimes/win7-x86/native
bin/Debug/net7.0/publish/runtimes/win7-x86/native/sqlite3.dll
bin/Debug/net7.0/publish/runtimes/android-arm
bin/Debug/net7.0/publish/runtimes/android-arm/native
bin/Debug/net7.0/publish/runtimes/android-arm/native/libMicrosoft.CognitiveServices.Speech.core.so
bin/Debug/net7.0/publish/runtimes/android-arm/native/libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so
bin/Debug/net7.0/publish/runtimes/android-arm/native/libMicrosoft.CognitiveServices.Speech.extension.kws.ort.so
bin/Debug/net7.0/publish/runtimes/android-arm/native/libMicrosoft.CognitiveServices.Speech.extension.lu.so
bin/Debug/net7.0/publish/runtimes/android-arm/native/libMicrosoft.CognitiveServices.Speech.extension.kws.so
bin/Debug/net7.0/publish/runtimes/linux-arm
bin/Debug/net7.0/publish/runtimes/linux-arm/lib
bin/Debug/net7.0/publish/runtimes/linux-arm/lib/netstandard2.0
bin/Debug/net7.0/publish/runtimes/linux-arm/lib/netstandard2.0/Microsoft.CognitiveServices.Speech.csharp.dll
bin/Debug/net7.0/publish/runtimes/linux-arm/native
bin/Debug/net7.0/publish/runtimes/linux-arm/native/libMicrosoft.CognitiveServices.Speech.core.so
bin/Debug/net7.0/publish/runtimes/linux-arm/native/libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so
bin/Debug/net7.0/publish/runtimes/linux-arm/native/libMicrosoft.CognitiveServices.Speech.extension.mas.so
bin/Debug/net7.0/publish/runtimes/linux-arm/native/libSystem.IO.Ports.Native.so
bin/Debug/net7.0/publish/runtimes/linux-arm/native/libMicrosoft.CognitiveServices.Speech.extension.kws.ort.so
bin/Debug/net7.0/publish/runtimes/linux-arm/native/libMicrosoft.CognitiveServices.Speech.extension.lu.so
bin/Debug/net7.0/publish/runtimes/linux-arm/native/libMicrosoft.CognitiveServices.Speech.extension.kws.so
bin/Debug/net7.0/publish/runtimes/linux-arm/native/libMicrosoft.CognitiveServices.Speech.extension.codec.so
bin/Debug/net7.0/publish/runtimes/linux
bin/Debug/net7.0/publish/runtimes/linux/lib
bin/Debug/net7.0/publish/runtimes/linux/lib/net7.0
bin/Debug/net7.0/publish/runtimes/linux/lib/net7.0/System.Data.Odbc.dll
bin/Debug/net7.0/publish/runtimes/tvos
bin/Debug/net7.0/publish/runtimes/tvos/lib
bin/Debug/net7.0/publish/runtimes/tvos/lib/net7.0
bin/Debug/net7.0/publish/runtimes/tvos/lib/net7.0/System.Data.Odbc.dll
bin/Debug/net7.0/publish/runtimes/win-x86
bin/Debug/net7.0/publish/runtimes/win-x86/native
bin/Debug/net7.0/publish/runtimes/win-x86/native/Microsoft.CognitiveServices.Speech.extension.kws.dll
bin/Debug/net7.0/publish/runtimes/win-x86/native/Microsoft.CognitiveServices.Speech.extension.mas.dll
bin/Debug/net7.0/publish/runtimes/win-x86/native/Microsoft.CognitiveServices.Speech.extension.audio.sys.dll
bin/Debug/net7.0/publish/runtimes/win-x86/native/Microsoft.CognitiveServices.Speech.extension.lu.dll
bin/Debug/net7.0/publish/runtimes/win-x86/native/Microsoft.CognitiveServices.Speech.extension.codec.dll
bin/Debug/net7.0/publish/runtimes/win-x86/native/Microsoft.CognitiveServices.Speech.core.dll
bin/Debug/net7.0/publish/runtimes/win-x86/native/Microsoft.CognitiveServices.Speech.extension.kws.ort.dll
bin/Debug/net7.0/publish/runtimes/win-x86/native/libSkiaSharp.dll
bin/Debug/net7.0/publish/runtimes/unix
bin/Debug/net7.0/publish/runtimes/unix/lib
bin/Debug/net7.0/publish/runtimes/unix/lib/net7.0
bin/Debug/net7.0/publish/runtimes/unix/lib/net7.0/System.IO.Ports.dll
bin/Debug/net7.0/publish/runtimes/osx-x64
bin/Debug/net7.0/publish/runtimes/osx-x64/lib
bin/Debug/net7.0/publish/runtimes/osx-x64/lib/netstandard2.0
bin/Debug/net7.0/publish/runtimes/osx-x64/lib/netstandard2.0/Microsoft.CognitiveServices.Speech.csharp.dll
bin/Debug/net7.0/publish/runtimes/osx-x64/native
bin/Debug/net7.0/publish/runtimes/osx-x64/native/libsqlite3.dylib
bin/Debug/net7.0/publish/runtimes/osx-x64/native/libSystem.IO.Ports.Native.dylib
bin/Debug/net7.0/publish/runtimes/osx-x64/native/libMicrosoft.CognitiveServices.Speech.core.dylib
bin/Debug/net7.0/publish/runtimes/ios-arm64
bin/Debug/net7.0/publish/runtimes/ios-arm64/native
bin/Debug/net7.0/publish/runtimes/ios-arm64/native/libMicrosoft.CognitiveServices.Speech.core.a
bin/Debug/net7.0/publish/runtimes/linux-arm64
bin/Debug/net7.0/publish/runtimes/linux-arm64/lib
bin/Debug/net7.0/publish/runtimes/linux-arm64/lib/netstandard2.0
bin/Debug/net7.0/publish/runtimes/linux-arm64/lib/netstandard2.0/Microsoft.CognitiveServices.Speech.csharp.dll
bin/Debug/net7.0/publish/runtimes/linux-arm64/native
bin/Debug/net7.0/publish/runtimes/linux-arm64/native/libMicrosoft.CognitiveServices.Speech.core.so
bin/Debug/net7.0/publish/runtimes/linux-arm64/native/libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so
bin/Debug/net7.0/publish/runtimes/linux-arm64/native/libMicrosoft.CognitiveServices.Speech.extension.mas.so
bin/Debug/net7.0/publish/runtimes/linux-arm64/native/libSystem.IO.Ports.Native.so
bin/Debug/net7.0/publish/runtimes/linux-arm64/native/libMicrosoft.CognitiveServices.Speech.extension.kws.ort.so
bin/Debug/net7.0/publish/runtimes/linux-arm64/native/libMicrosoft.CognitiveServices.Speech.extension.lu.so
bin/Debug/net7.0/publish/runtimes/linux-arm64/native/libMicrosoft.CognitiveServices.Speech.extension.kws.so
bin/Debug/net7.0/publish/runtimes/linux-arm64/native/libMicrosoft.CognitiveServices.Speech.extension.codec.so
bin/Debug/net7.0/publish/runtimes/maccatalyst-x64
bin/Debug/net7.0/publish/runtimes/maccatalyst-x64/native
bin/Debug/net7.0/publish/runtimes/maccatalyst-x64/native/libMicrosoft.CognitiveServices.Speech.core.a
bin/Debug/net7.0/publish/runtimes/win7-x64
bin/Debug/net7.0/publish/runtimes/win7-x64/native
bin/Debug/net7.0/publish/runtimes/win7-x64/native/sqlite3.dll
bin/Debug/net7.0/publish/runtimes/win10-arm
bin/Debug/net7.0/publish/runtimes/win10-arm/native
bin/Debug/net7.0/publish/runtimes/win10-arm/native/Microsoft.CognitiveServices.Speech.extension.kws.dll
bin/Debug/net7.0/publish/runtimes/win10-arm/native/Microsoft.CognitiveServices.Speech.extension.mas.dll
bin/Debug/net7.0/publish/runtimes/win10-arm/native/Microsoft.CognitiveServices.Speech.extension.audio.sys.dll
bin/Debug/net7.0/publish/runtimes/win10-arm/native/Microsoft.CognitiveServices.Speech.extension.lu.dll
bin/Debug/net7.0/publish/runtimes/win10-arm/native/Microsoft.CognitiveServices.Speech.core.dll
bin/Debug/net7.0/publish/runtimes/win10-arm/native/Microsoft.CognitiveServices.Speech.extension.kws.ort.dll
bin/Debug/net7.0/publish/runtimes/android-arm64
bin/Debug/net7.0/publish/runtimes/android-arm64/native
bin/Debug/net7.0/publish/runtimes/android-arm64/native/libMicrosoft.CognitiveServices.Speech.core.so
bin/Debug/net7.0/publish/runtimes/android-arm64/native/libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so
bin/Debug/net7.0/publish/runtimes/android-arm64/native/libMicrosoft.CognitiveServices.Speech.extension.kws.ort.so
bin/Debug/net7.0/publish/runtimes/android-arm64/native/libMicrosoft.CognitiveServices.Speech.extension.lu.so
bin/Debug/net7.0/publish/runtimes/android-arm64/native/libMicrosoft.CognitiveServices.Speech.extension.kws.so
bin/Debug/net7.0/publish/runtimes/win-arm64
bin/Debug/net7.0/publish/runtimes/win-arm64/native
bin/Debug/net7.0/publish/runtimes/win-arm64/native/libSkiaSharp.dll
bin/Debug/net7.0/publish/runtimes/osx
bin/Debug/net7.0/publish/runtimes/osx/lib
bin/Debug/net7.0/publish/runtimes/osx/lib/net7.0
bin/Debug/net7.0/publish/runtimes/osx/lib/net7.0/System.Data.Odbc.dll
bin/Debug/net7.0/publish/runtimes/osx/native
bin/Debug/net7.0/publish/runtimes/osx/native/libSkiaSharp.dylib
bin/Debug/net7.0/publish/runtimes/iossimulator-arm64
bin/Debug/net7.0/publish/runtimes/iossimulator-arm64/native
bin/Debug/net7.0/publish/runtimes/iossimulator-arm64/native/libMicrosoft.CognitiveServices.Speech.core.a
bin/Debug/net7.0/publish/runtimes/linux-x64
bin/Debug/net7.0/publish/runtimes/linux-x64/lib
bin/Debug/net7.0/publish/runtimes/linux-x64/lib/netstandard2.0
bin/Debug/net7.0/publish/runtimes/linux-x64/lib/netstandard2.0/Microsoft.CognitiveServices.Speech.csharp.dll
bin/Debug/net7.0/publish/runtimes/linux-x64/native
bin/Debug/net7.0/publish/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.core.so
bin/Debug/net7.0/publish/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so
bin/Debug/net7.0/publish/runtimes/linux-x64/native/libsqlite3.so
bin/Debug/net7.0/publish/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.extension.mas.so
bin/Debug/net7.0/publish/runtimes/linux-x64/native/libSystem.IO.Ports.Native.so
bin/Debug/net7.0/publish/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.extension.kws.ort.so
bin/Debug/net7.0/publish/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.extension.lu.so
bin/Debug/net7.0/publish/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.extension.kws.so
bin/Debug/net7.0/publish/runtimes/linux-x64/native/libMicrosoft.CognitiveServices.Speech.extension.codec.so
bin/Debug/net7.0/publish/runtimes/illumos
bin/Debug/net7.0/publish/runtimes/illumos/lib
bin/Debug/net7.0/publish/runtimes/illumos/lib/net7.0
bin/Debug/net7.0/publish/runtimes/illumos/lib/net7.0/System.Data.Odbc.dll
bin/Debug/net7.0/publish/runtimes/win
bin/Debug/net7.0/publish/runtimes/win/lib
bin/Debug/net7.0/publish/runtimes/win/lib/net7.0
bin/Debug/net7.0/publish/runtimes/win/lib/net7.0/System.IO.Ports.dll
bin/Debug/net7.0/publish/runtimes/win/lib/net7.0/System.Data.Odbc.dll
bin/Debug/net7.0/publish/runtimes/win-x64
bin/Debug/net7.0/publish/runtimes/win-x64/native
bin/Debug/net7.0/publish/runtimes/win-x64/native/Microsoft.CognitiveServices.Speech.extension.kws.dll
bin/Debug/net7.0/publish/runtimes/win-x64/native/Microsoft.CognitiveServices.Speech.extension.mas.dll
bin/Debug/net7.0/publish/runtimes/win-x64/native/Microsoft.CognitiveServices.Speech.extension.audio.sys.dll
bin/Debug/net7.0/publish/runtimes/win-x64/native/Microsoft.CognitiveServices.Speech.extension.lu.dll
bin/Debug/net7.0/publish/runtimes/win-x64/native/Microsoft.CognitiveServices.Speech.extension.codec.dll
bin/Debug/net7.0/publish/runtimes/win-x64/native/Microsoft.CognitiveServices.Speech.core.dll
bin/Debug/net7.0/publish/runtimes/win-x64/native/Microsoft.CognitiveServices.Speech.extension.kws.ort.dll
bin/Debug/net7.0/publish/runtimes/win-x64/native/libSkiaSharp.dll
bin/Debug/net7.0/publish/runtimes/android-x86
bin/Debug/net7.0/publish/runtimes/android-x86/native
bin/Debug/net7.0/publish/runtimes/android-x86/native/libMicrosoft.CognitiveServices.Speech.core.so
bin/Debug/net7.0/publish/runtimes/android-x86/native/libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so
bin/Debug/net7.0/publish/runtimes/android-x86/native/libMicrosoft.CognitiveServices.Speech.extension.kws.ort.so
bin/Debug/net7.0/publish/runtimes/android-x86/native/libMicrosoft.CognitiveServices.Speech.extension.lu.so
bin/Debug/net7.0/publish/runtimes/android-x86/native/libMicrosoft.CognitiveServices.Speech.extension.kws.so
bin/Debug/net7.0/publish/runtimes/android-x64
bin/Debug/net7.0/publish/runtimes/android-x64/native
bin/Debug/net7.0/publish/runtimes/android-x64/native/libMicrosoft.CognitiveServices.Speech.core.so
bin/Debug/net7.0/publish/runtimes/android-x64/native/libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so
bin/Debug/net7.0/publish/runtimes/android-x64/native/libMicrosoft.CognitiveServices.Speech.extension.kws.ort.so
bin/Debug/net7.0/publish/runtimes/android-x64/native/libMicrosoft.CognitiveServices.Speech.extension.lu.so
bin/Debug/net7.0/publish/runtimes/android-x64/native/libMicrosoft.CognitiveServices.Speech.extension.kws.so
bin/Debug/net7.0/publish/runtimes/win10-arm64
bin/Debug/net7.0/publish/runtimes/win10-arm64/native
bin/Debug/net7.0/publish/runtimes/win10-arm64/native/Microsoft.CognitiveServices.Speech.extension.kws.dll
bin/Debug/net7.0/publish/runtimes/win10-arm64/native/Microsoft.CognitiveServices.Speech.extension.mas.dll
bin/Debug/net7.0/publish/runtimes/win10-arm64/native/Microsoft.CognitiveServices.Speech.extension.audio.sys.dll
bin/Debug/net7.0/publish/runtimes/win10-arm64/native/Microsoft.CognitiveServices.Speech.extension.lu.dll
bin/Debug/net7.0/publish/runtimes/win10-arm64/native/Microsoft.CognitiveServices.Speech.core.dll
bin/Debug/net7.0/publish/runtimes/win10-arm64/native/Microsoft.CognitiveServices.Speech.extension.kws.ort.dll
bin/Debug/net7.0/publish/runtimes/solaris
bin/Debug/net7.0/publish/runtimes/solaris/lib
bin/Debug/net7.0/publish/runtimes/solaris/lib/net7.0
bin/Debug/net7.0/publish/runtimes/solaris/lib/net7.0/System.Data.Odbc.dll
bin/Debug/net7.0/publish/runtimes/osx-arm64
bin/Debug/net7.0/publish/runtimes/osx-arm64/lib
bin/Debug/net7.0/publish/runtimes/osx-arm64/lib/netstandard2.0
bin/Debug/net7.0/publish/runtimes/osx-arm64/lib/netstandard2.0/Microsoft.CognitiveServices.Speech.csharp.dll
bin/Debug/net7.0/publish/runtimes/osx-arm64/native
bin/Debug/net7.0/publish/runtimes/osx-arm64/native/libSystem.IO.Ports.Native.dylib
bin/Debug/net7.0/publish/runtimes/osx-arm64/native/libMicrosoft.CognitiveServices.Speech.core.dylib
bin/Debug/net7.0/publish/runtimes/ios
bin/Debug/net7.0/publish/runtimes/ios/lib
bin/Debug/net7.0/publish/runtimes/ios/lib/net7.0
bin/Debug/net7.0/publish/runtimes/ios/lib/net7.0/System.Data.Odbc.dll
bin/Debug/net7.0/publish/runtimes/iossimulator-x64
bin/Debug/net7.0/publish/runtimes/iossimulator-x64/native
bin/Debug/net7.0/publish/runtimes/iossimulator-x64/native/libMicrosoft.CognitiveServices.Speech.core.a
bin/Debug/net7.0/publish/runtimes/freebsd
bin/Debug/net7.0/publish/runtimes/freebsd/lib
bin/Debug/net7.0/publish/runtimes/freebsd/lib/net7.0
bin/Debug/net7.0/publish/runtimes/freebsd/lib/net7.0/System.Data.Odbc.dll
bin/Debug/net7.0/publish/runtimes/maccatalyst-arm64
bin/Debug/net7.0/publish/runtimes/maccatalyst-arm64/native
bin/Debug/net7.0/publish/runtimes/maccatalyst-arm64/native/libMicrosoft.CognitiveServices.Speech.core.a
bin/Debug/net7.0/publish/runtimes/centos7-x64
bin/Debug/net7.0/publish/runtimes/centos7-x64/native
bin/Debug/net7.0/publish/runtimes/centos7-x64/native/libMicrosoft.CognitiveServices.Speech.core.so
bin/Debug/net7.0/publish/runtimes/centos7-x64/native/libMicrosoft.CognitiveServices.Speech.extension.audio.sys.so
bin/Debug/net7.0/publish/runtimes/centos7-x64/native/libMicrosoft.CognitiveServices.Speech.extension.mas.so
bin/Debug/net7.0/publish/runtimes/centos7-x64/native/libMicrosoft.CognitiveServices.Speech.extension.kws.ort.so
bin/Debug/net7.0/publish/runtimes/centos7-x64/native/libMicrosoft.CognitiveServices.Speech.extension.lu.so
bin/Debug/net7.0/publish/runtimes/centos7-x64/native/libMicrosoft.CognitiveServices.Speech.extension.kws.so
bin/Debug/net7.0/publish/runtimes/centos7-x64/native/libMicrosoft.CognitiveServices.Speech.extension.codec.so
bin/Debug/net7.0/publish/System.Data.Odbc.dll
bin/Debug/net7.0/publish/SkiaSharp.dll
bin/Debug/net7.0/publish/app.deps.json