I've found this in the Scott Hanselman's blog post Brainstorming - Creating a small single self-contained executable out of a .NET Core application and I tried it and it works like a charm!

It not only compiles but also runs perfectly well. I also compiled it with the option -l aggressive and its size dropped from 56MB to 47MB. I love it, really. I think we should consider using this dotnet tool.
This is great! Will definitely look into it and probably ship like this from now on.
You should wait, .NET Core 3.0 will have this out of the box. See design proposal on https://github.com/dotnet/designs/pull/52
Another solution, is to use https://github.com/dotnet/corert (I am 70% sure it generates 1 file as well)
CoreRT is a ahead of time compiler. It basically compile your executable directly in the target architecture. (No IL)
This mean faster startup and smaller binary. But the problem is that if you use reflection, you need to document it specifically in a separate file.
You should wait, .NET Core 3.0 will have this out of the box. See design proposal on dotnet/designs#52
I don't agree. Whatever we have today will be better in a future leads to paralysis? Why waiting?This is something we can do right now and works okay, if in the near future .NET Core 3.0 comes with a better tool then we can use that one.
True. I am surprised it works. Apparently -l aggressive is using ILLinker, which start pruning the wrong stuff if you use reflection. (As it has no way to know in advance that what it pruned would be used by reflection)
I think avalonia use reflection extensively.
Actually I'm surprised to work, too, because we have the "dummyhack", which makes sure the Extensions folder is present relative to the exe. Otherwise the software fails.
Also, did you try it with deleting the data folder? We should have the Tor binaries relative to the exe, too, except if Tor is already copied to the data folder.
It does work. I tried deleting the data folder and it worked perfectly well too. I can see it runs the tor instance in the recently created data folder with:
/bin/sh -c LD_LIBRARY_PATH=$LD_LIBRARY_PATH:=/home/lontivero/.walletwasabi/client/tor/Tor && export LD_LIBRARY_PATH && cd /home/lontivero/.walletwasabi/client/tor/Tor && ./tor --SOCKSPort 127.0.0.1:9050 --Log "notice file /home/lontivero/.walletwasabi/client/TorLogs.txt"
Someone asked for:
Can you please provide (sic) a standalone portable executable for linux, that doesn't require installation.
This is exactly that.
this is awesome. I am very surprised about why it works. For example, NBitcoin use reflection internally for message parsing. I was expecting the aggressive optimization to strip out reflection metadata and crash NBitcoin.
I didn't test it. I just compile it, ran it and created a new Wallet (i tried with existing wallets too) and everything looked okay at a first glance. Of course if we agree with the concept then we would need to test it seriously.
Yeah, you should try to run the tests on this.
We've been working on things those we know that our dependencies will fix in the future. For this situation I added a new tag, called "waiting for dependency." In this case we're waiting for .NET Core 3.0 to progress forward with this issue.
@molnard @nopara73 @lontivero this still is working with master branch :D using this command:
dotnet publish --configuration Release --force --self-contained true --runtime "linux-x64" /p:PublishSingleFile=true /p:DebugType=none /p:DebugSymbols=false /p:ErrorReport=none /p:Deterministic=True
It doesn't work for me. It still copy all the .dll
check the "publish" folder, in my example it was: WalletWasabi/WalletWasabi.Gui/bin/Release/netcoreapp3.1/linux-x64/publish/
@jmacato I discourage the self-contained option for now.
This is a hack, it is actually a self extracting file, it put Wasabi files inside some temp folder. Removing the .exe does not remove the app from the drive as it has been unzipped in temp files.
I think .NET 5.0 wants to improve this
@NicolasDorier yeah.. and also i was disappointed with the file size too... i'll give CoreRT a shot after we do 0.10 integration
please give feedback on https://github.com/dotnet/corert/issues/7200 then
Maybe its worth checking these docs. I played with it in Wasabi a time ago. And it was yielding pretty good results.
This issue seems for Windows (change the title?), for Linux, we have #1179
This is different, it is not related to the OS - you can publish the app with dotnet core in a single file format.
We should close this issue because it will not be a thing anytime soon. Feel free to reopen it if you disagree with me.
Most helpful comment
You should wait, .NET Core 3.0 will have this out of the box. See design proposal on https://github.com/dotnet/designs/pull/52