19 ms·
> In .NET 6, in-memory single file apps have been enabled for Windows and macOS. In .NET 5, this deployment type was limited to Linux. You can now publish a sin
by abdusco 5y ago
> In .NET 6, in-memory single file apps have been enabled for Windows and macOS. In .NET 5, this deployment type was limited to Linux. You can now publish a single-file binary that is both deployed and launched as a single file, for all supported OSes. Single files apps no longer extract any core runtime assemblies to temporary directories.
This is a great! Now I can publish statically linked executables and run it everywhere. I don't have to tolerate Golang and its quirks just to have cross-compilation and static binaries, even though they will be larger in size.
- _th_a_w_111 5y agoFirst comment in this thread and it already contains unqualified bashing of other languages. Just don't do it.
- kreeben 5y ago>> Single files apps no longer extract any core runtime assemblies to temporary directories I might be ignorant here but if you're not specifically pointing out what version DLL's you want, aren't you in fact publishing a dynamically linked executable instead of a statically linked one? Doesn't these single-file apps rely on the GAC?
- sedatk 5y agoThe whole runtime gets included in the binary.
- BiteCode_dev 5y agoDoes this mean you need one binary per OS so that the runtime matches, or do they do some magic so that one single binary can run on all Oses ?
- sebastienros 5y agoYou create one binary per OS.
- jonathanlydall 5y agoYou create a single binary which has the runtime and dependencies self contained within. You of course have to choose your target platform for this as it makes .exes for Windows, ELFs for Linux, etc. If you want you can still choose to distribute IL DLLs and users then use their already installed dotnet on their machine to run them.
- e12e 5y ago> You of course have to choose your target platform for this (...) https://github.com/jart/cosmopolitan https://github.com/jart/cosmopolitan (but, yeah, you probably want one version per target, even if hacks are cool)
- kingcharles 5y agoThis actually makes sense in 2021 since we have the resources to allow things like this. 20 years ago this might have seemed insane.
- vidanay 5y ago30 years ago we used DOS and DLL Hell was a completely unknown concept. We did have to deal with himem.sys though.
- justin66 5y agoOn the contrary, 30 years ago we were using Windows 3.0, which is about when dll hell started being a real thing. (DLL hell stopped being a problem a lot sooner than you probably think, too...)
- nisegami 5y ago>DLL hell stopped being a problem a lot sooner than you probably think, too Does not match my experience at work unfortunately.
- justin66 5y agoIf you're seeing this on any version of Windows made in the last 22 years or so, it's because a software developer fucked up in a really creative way. My condolences. Sometimes the issue is that people have tended to conflate "dll hell" and "dependency hell." That's an old pet peeve of mine and I realize it doesn't matter...
- ourmandave 5y ago"Insert floppy disk 435 of 880 and press [Enter] when ready..."
- vidanay 5y agoInvalid media type Abort, Retry, Fail? FFFFFFFUUUUUUUUCCCCCCKKKKK!!!!!!
- Rebelgecko 5y agoHow much does this add to the binary's size?
- aha_throwaway 5y agoIn my case about 60MB
- ripley12 5y agoSomething like 60MB if the application is not trimmed. Closer to 10MB if the application can be trimmed.
- voxic11 5y agoThere is no GAC. > .NET Core and .NET 5 and later versions eliminate the concept of the global assembly cache (GAC)
- backoncemore 5y agoInteresting. I haven't worked in .NET for several years now, but the GAC was always an absolute headache to deal with.
- exyi 5y agoThankfully they did not port this hell to Linux
- cm2187 5y agoSurely the binaries generated by the JIT still get cached somewhere?
- h3h3 5y agoyou can set a ReadyToRun flag on publish which pre jits your dlls https://docs.microsoft.com/en-us/dotnet/core/deploying/ready-to-run https://docs.microsoft.com/en-us/dotnet/core/deploying/ready...
- malkia 5y agoFor an internal tool that reformats our code base, I've used that to pack the `dotnet format` (although technically, not allowed case, since it's a tool, and need to be run from an "sdk" environment). It works for what we use it (whitespace formatting, but not for msbuild/analysis - which is clearly understood). One thing though, is that native .dlls are still outside (DetoursServices.dll for example in BuildXL). But still pretty impressive what it can done. That, and the new embedded .pdb (for .NET only, e.g. not native). I wish "publish" was used more by the place I work for (most of the folks would simply Release (F5) and store what's there in p4). I've only recently discovered about "publish" and that is after haven't worked with .NET for so long...
- jmnicolas 5y agoYeah "publish" is magical, I specifically jumped from .net 4.8 to 5 just for this feature.
- merb 5y agomsbuild had publish since at least .net 3.5 (when I started to use the platform) it was just a little bit akward to use tough. and of course dotnet publish is 1000x better than msbuild with it's obscure syntax (which got way better in .net5 and 6 with -p: syntax, etc.)
- ygra 5y ago-p:Property=Value (or /p: Property=Value) has existed in Ms build since the beginning. That's not a .NET 5 or 6 thing.
- malkia 5y agoAlso If I'm not mistaken most of the properties (if not all) can be set through the command-line (for good and bad :)), e.g. `set Property=Value && msbuild` or `Property=Value msbuild` (on unix systems)
- jmnicolas 5y ago
- azth 5y agoYou should also be able to do this in Java with jlink.
- vb6sp6 5y agoyes but then you have to write your program in java
- kreeben 5y agoand now you have two problems
- azth 5y agoYes, arguably a better decision than writing it in golang to begin with.
- naikrovek 5y agoGo is better than Java any day of any week if startup time or memory footprint are of any concern to you at all. Also Java is OO which is... terrible to say the least.
- pjmlp 5y agoJava has had AOT compilation since around 2000, just not as free beer. In 2021, the AOT free beer exists, as do JIT caches. As for OO model, I rather be able to understand which interfaces a type implements by looking at it, instead of producing compiler errors, or have a type by accident supporting a single method interface with complete different semantics.
- polskibus 5y agoWhat do you mean by golang quirks?
- abdusco 5y agoNo passable debugger, weird typing system, verbose error handling, lack of exceptions, generics, syntactic sugar ... I'm a novice at Golang, and I dislike much of the language, except that it's fast and can produce small binaries.
- Thaxll 5y ago"verbose error handling, lack of exceptions" Exactly why I prefer Go to Java and C#.
- exyi 5y agoUnderstandable, but it's a matter of taste. For people who prefer a language with exception, it's good that there now exist a viable solution other than sticking to a language that might not fit their taste so well. It seems to me that F# could get a bit more love from HN-style nerds. Obviously, it's more similar to C# than Golang, but specifically error handling can be done in much nicer way using the Result type.
- grumpyprole 5y agoBut Go has no sum types either!
- ClumsyPilot 5y agoI can live with many things, but no generics in 2021? Over my dead body!
- TylerE 5y agoSounds like you want nim.
- abdusco 5y ago
- dsizzle 5y agoKind of curious that Microsoft had a feature that was available in Linux but not Windows, no?
- exyi 5y agoYea, funny :D However, the problem was mostly deploying dotnet apps on servers which did not have dotnet installed. Windows has .NET installed anyway, so there the problem did not really exist
- oaiey 5y ago.NET (Core) 5 is not installed on Windows. Windows comes with .NET Framework 4.x. I think the user interest was startup times of lambdas and containers. Therefore Linux was a priority.
- Mountain_Skies 5y agoSeem to recall this happening several time with Microsoft Office for Mac getting certain features before Office for Windows did.
- mrweasel 5y agoWait, wait… .Net can build “static linked” executables that doesn’t require that I install .Net to run? I had no idea, I guess it’s time to revisit .Net
- abdusco 5y agoThat's exactly what it is. You can even cross-compile for all supported platforms. $ dotnet new console -n HelloWorld $ dotnet publish --project HelloWorld -r osx-arm64 --self-contained -o out -p:PublishTrimmed=true $ du -sh out 10M
- qwertox 5y agoWow... I didn't know. Since when can it do this?
- chunkyks 5y agoI've been using this for at least a year or two. With their stripping, my binaries (which use very little other than system.* and math.*) are 12M in size on each OS. I tested with today's release of version six, the binaries are about 1M smaller each.
- tester756 5y agoI believe it was introduced around .NET Core 5? or 3? so at least 1 year ago
- metaltyphoon 5y agoSince .net core 3.0
- the_arun 5y agoI haven't used .net. But how memory management happens when you are running a binary executable? Does it have a builtin CLR (Common Language Runtime[1])? Because CLR provides the tools for managing memory & security? [1] https://en.wikipedia.org/wiki/Common_Language_Runtime https://en.wikipedia.org/wiki/Common_Language_Runtime
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- spaetzleesser 5y agoLast time I tried it, single-file binaries were super slow on first load. It was one of the reasons we went back to .NET framework. Has this improved?
- dotancohen 5y agoI wish that I knew about this earlier. I'm a Linux user but I love C#. I suppose that VS Code is the canonical IDE for C# today?
- ed_elliott_asc 5y agoNo visual studio or rider, vscode support isn’t great from my experience.
- dotancohen 5y agoThanks. I love the Jetbrains IDEs.
- DeathArrow 5y agoFor Linux you can use either VS Code or Rider.
- dotancohen 5y agoTerrific, thank you.