C
C#

help

❔ Problems with using Dotnet 6 on Windows to publish to an exe format

Llpha3ch02/3/2023
Dotnet/C# newb here. Previously I've only done a small amount of development using the .Net Framework on Windows in Visual Studio Community where switching between publishing an exe or dll is straightforward and easy. Now I'm trying to get familiar with publishing C#/Dotnet 6 cross platform apps in Visual Studio. I've googled this and followed guides I've found and still can't get VS to output an exe. How do I do this, and does it always have to result in a huge file size, like in standalone option, without having a separate exe and dll? When I publish to Windows, I'd prefer an exe without having to bundle a dll with it, and without it being 34MB. Am I stuck with creating projects targeting .Net Framework to get what I need? To clarify, when I've tried publishing in the Linux command line, a standalone executable was 34MB.
Jjcotton422/3/2023
I haven't used VS' publishing in forever, but the default behavior of dotnet publish on the CLI is a framework-dependent deployment that is, the user must already have the runtime installed on their machine (if your app has an installer, it could just install it of course) it sounds like you may have been doing a self-contained publish, which bundles the runtime with your app there are things like trimming you can use to cut down on the deployment size, but how well they work depends on the type of app eg GUI apps don't tend to trim very well
BBecquerel2/3/2023
it is possible to publish to a single-file that isn't 30mb large. you want to look up assembly trimming
BBecquerel2/3/2023
Trim self-contained applications - .NET
Learn how to trim self-contained apps to reduce their size. .NET Core bundles the runtime with an app that is published self-contained and generally includes more of the runtime then is necessary.
BBecquerel2/3/2023
in short add <PublishTrimmed>true</PublishTrimmed> to your csproj and i think that will do most of the heavy lifting i think a helloworld console app is 3-5mb like this
Llpha3ch02/3/2023
Thanks for the replies!
BBecquerel2/3/2023
no prob
AAccord2/4/2023
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
❔ Using net7 documentation while targeting netstandard2.0This might be a bit of a dumb question, but is there anyway to make omnisharp/roslyn's tooltips use ❔ WPF app unit testingI am learning how to make unit tests. I built my app on .net core 6.0 and I created class library (o❔ where exactly should i put authorizationso i read a few posts on where to put authorization and most of the people agree on putting it in th❔ C# WPF playing background musicHello, I have WPF app for game launcher/updater. I wanted to add background music, so I added this cC# wpf mvvm Datagrid filter using LINQSo here I have a MVVM form. the Form contains a Datagrid which is connected to the Databank. I also ❔ Is it worth to create lazy dictionary in this case?I have following class: so as you see Add function add to the dictionary class TreeNode, it looks li❔ Going to use a listbox with a switch for something in the morning, need help with format for bothI would like to set two variables with a listbox using a switch and one variable with a second listb✅ What's your view on tool like Sonarqube?Should I learn from the code smells it captures?✅ Autodesk Maya HelpAnyone in here know Autodesk Maya really well? My mesh tool isn't letting my polygon primitives mesh❔ circular primesso this program is meant to find how many circular primes there are below 1 million (should be 55), ❔ WPF Cannot find child when it's thereHi! I am working on my own RoundedCorners attachedproperty however I have stumbled upon a problem Pr❔ HttpClient exiting program during GetStringAsync() and GetAsync()I'm sending a GET to an API, but when debugging, as soon as you step off the last line, it cuts out ✅ Homework Helphttps://i.gyazo.com/f23d758d46581bcfb84f88d4178cd484.png What should I return from the FillArray() ❔ force a ushort value?if i type for example var num = 25L; i am forcing a long value (int64) how can i force a ushort in ❔ Doing post method with entity frameworki'm making a simple API to practice with entity framework but when i try to make a post to a table w❔ I can't reference a class library please helpI can't reference a class library i t says compilation error❔ ASP.NET REMOTE DEVELOPMENTHey does anyone know if I would need nginx for remote development on a ubuntu server from my windowException/NULL/Error handling advice.DeserializeAsync clearly returns a nullable generic object. From the picture we can clearly see that❔ ASP.NET Core web app vs ASP.net web application(.NET Framework)Hi, Ive been working with c# for a while now and would like to make a webapp but I dont know where t✅ IGNORE PEOPLEmy place for testing commands