❔ how to export project to .exe
Hey I have a project I'm trying to export to .exe. I see a lot of videos but their layout looks different. I have 2019 and 2022 installed. I'm using newest version of .net framework. I do not have one click which is what I think makes the .exe instead of manifests.
114 Replies
Newest version of .NET or of .NET Framework?
In any case, the publish wizard should guide you
I just noticed I had 4.7 as my framework... I downloaded 7.0 but I'm not seeing it as a selection for target framework
This is what I downloaded
so the project is .net framework
Yes
This isn't what the YouTube videos show when they click public but this is my public
If you made the project with .NET Framework, switching it to .NET Core or .NET is not simple, hence it doesn't show up in the version selector
$newproject
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework.
.NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended.
https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
Well, click through the wizard and see what happens
So I can't get a .exe from a .netframework forms?
You can
How so?
I'll show u what it installs one sec
But inside application files is just manifests, no exe
When I run setup it just gives an app no .exe compiled
You probably told the wizard to create some setup with an installer, ClickOnce, or something like that
When I run setup, it gives this
I never had that option. I just told it to download to folder
This is the option I select
So you are creating an installer
Then this.
I'm not wanting an installer.... it gives me no other choices
Change the output type?
To?
Idk, it's been ages since I used the ancient Framework last
What are the types available?
None of them seem correct
¯\_(ツ)_/¯ then
Other than application
Fck
Thanks for trying 😄
And for future reference, don't use .NET Framework unless you really hate yourself
.NET is the way to go
Ok
I can rebuild the project
I mean, if you want to, sure
You can use Upgrade Assistant to upgrade the project to .NET 7
Or you can create a new, .NET 7 project, and just copy the code over
Chances are it'll work
I don't have an option without net framework
Upgrade assistant?
$newproject
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework.
.NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended.
https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
None of those options?
Yes that's not a thing on mine
Only some
I'll show u
Yes, Upgrade Assistant: https://dotnet.microsoft.com/en-us/platform/upgrade-assistant
Weird
Is this VS2022?
Let me verify it's not 2019
Ah 2022 has it
I'll try the upgrade assistant first
Ok installed that. Does it do it automatically?
I did
It's upgrading
Ok so I have a .exe but it only runs in my debug folder @ZZZZZZZZZZZZZZZZZZZZZZZZZ
Sent to my buddy and it won't load, I put it on my desktop and won't load
In debug? It loads
It's an exe and a bunch of other files, would be my guess?
All of them are needed
Unless you publish it in single-file mode
How can I compile them all into the exe?
$singlefile
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true
Use of -r
|--runtime
implies --self-contained true
. Add --self-contained false
to publish as runtime-dependent.
-r RID
and -p:PublishSingleFile=true
can be moved to .csproj as the following properties:but to target multiple RIDs, you have to use dotnet publish
with the -r
option for each RID.
You can also add -p:IncludeNativeLibrariesForSelfExtract=true
to include native libraries (like Common Language Runtime dlls) in the output executable.
You might want to instead publish your application compiled Ahead Of Time to native code, see $nativeaot for examples.
https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file
https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publishCreate a single file for application deployment - .NET
Learn what single file application is and why you should consider using this application deployment model.
.NET Runtime Identifier (RID) catalog
Learn about the runtime identifier (RID) and how RIDs are used in .NET.
Ok let me publish it
Here's how to do it from the CLI, but the wizard should have a checkbox as well
Through wizard. I can't run it on my desktop by itself
The docs are outdated. This is my picture of deployment
The output is
bin/Publish
not bin/Release
And don't deploy as ClickOnce
Nor to Azure
Publish to folderNo good. Just tried all of those
You're still looking into the
bin/Release
folderIm sending a list of pics
All the pics I'm sending do not work singled out
Yes
No exe
In the application files, it's all deploy files
It's not giving an exe
Idk then, try the CLI I guess
What file would I use it on? I tried it on sln and it wouldn't
MODiX#0152
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true
Use of -r
|--runtime
implies --self-contained true
. Add --self-contained false
to publish as runtime-dependent.
-r RID
and -p:PublishSingleFile=true
can be moved to .csproj as the following properties:but to target multiple RIDs, you have to use dotnet publish
with the -r
option for each RID.
You can also add -p:IncludeNativeLibrariesForSelfExtract=true
to include native libraries (like Common Language Runtime dlls) in the output executable.
You might want to instead publish your application compiled Ahead Of Time to native code, see $nativeaot for examples.
https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file
https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publishEmbed Type
Link
Quoted by
<@85903769203642368> from #how to export project to .exe (click here)
React with ❌ to remove this embed.
dotnet publish -r win-x64 BackupSystem.sln doesn't work when doing it
You need to enable file extensions to see the file extension….
Try using it on the project
Setup looks like an exe to me
Or just don't specify any file
Just cd into the solution directory and
Ur reading it wrong completely.
Where can I change my build folder?
So it will build in a different folder. This one became a mess
Just delete it then
You can safely delete the whole
bin
It has my sln in it....
how
It requires sln
Wtf
Yeah I'll send pic one sec
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true
Ignore that
When I ran it in my folder it tells me this
It contains only my project currently
Means you probably made the mistake of placing your project in the same folder as the solution
In that case, specify the project file
Ok
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true SPECIFY HERE?
I think so?
Specify the sln?
The csproj
The sln is the only thing I see close to that
Unless u mean form1
Because you have file extensions turned off
Or maybe not?
Why does this not have an extension?
My file extensions is on???
Well, that extension wasn't showing for some reason
Now it does show
Su, this is your
.csproj
fileOhhhhh
If I rename it to BackupSystem would it break everything
Idk, it might
How can I rename it then?
Properly
It can't have a space in it
Why?
Ok this is the same issue
So it compiled to an exe
Move exe to desktop, doesn't work. Keep in folder? Works
Yeah, at this point I've no clue what's going on
Omg I got it!!!!
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true --self-contained true BackupSystem.csproj
Missed the --self contained
I'm 100% saving this in my notes lmao
Ah, there you go
Tyvm @ZZZZZZZZZZZZZZZZZZZZZZZZZ !!!
Anytime
My first ever c# project is now complete >:D
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.