C
C#17mo ago
NullIntended

❔ 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
Angius
Angius17mo ago
Newest version of .NET or of .NET Framework? In any case, the publish wizard should guide you
NullIntended
NullIntendedOP17mo ago
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
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
This is what I downloaded
SG97
SG9717mo ago
so the project is .net framework
NullIntended
NullIntendedOP17mo ago
Yes
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
This isn't what the YouTube videos show when they click public but this is my public
Angius
Angius17mo ago
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
MODiX
MODiX17mo ago
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
Angius
Angius17mo ago
Well, click through the wizard and see what happens
NullIntended
NullIntendedOP17mo ago
So I can't get a .exe from a .netframework forms?
Angius
Angius17mo ago
You can
NullIntended
NullIntendedOP17mo ago
How so? I'll show u what it installs one sec
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
But inside application files is just manifests, no exe When I run setup it just gives an app no .exe compiled
Angius
Angius17mo ago
You probably told the wizard to create some setup with an installer, ClickOnce, or something like that
NullIntended
NullIntendedOP17mo ago
When I run setup, it gives this
NullIntended
NullIntendedOP17mo ago
I never had that option. I just told it to download to folder
NullIntended
NullIntendedOP17mo ago
This is the option I select
Angius
Angius17mo ago
So you are creating an installer
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
Then this. I'm not wanting an installer.... it gives me no other choices
Angius
Angius17mo ago
Change the output type?
NullIntended
NullIntendedOP17mo ago
To?
Angius
Angius17mo ago
Idk, it's been ages since I used the ancient Framework last What are the types available?
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
None of them seem correct
Angius
Angius17mo ago
¯\_(ツ)_/¯ then
NullIntended
NullIntendedOP17mo ago
Other than application Fck Thanks for trying 😄
Angius
Angius17mo ago
And for future reference, don't use .NET Framework unless you really hate yourself .NET is the way to go
NullIntended
NullIntendedOP17mo ago
Ok I can rebuild the project
Angius
Angius17mo ago
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
NullIntended
NullIntendedOP17mo ago
I don't have an option without net framework Upgrade assistant?
Angius
Angius17mo ago
$newproject
MODiX
MODiX17mo ago
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
Angius
Angius17mo ago
None of those options?
NullIntended
NullIntendedOP17mo ago
Yes that's not a thing on mine Only some I'll show u
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
Angius
Angius17mo ago
Weird Is this VS2022?
NullIntended
NullIntendedOP17mo ago
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?
NullIntended
NullIntendedOP17mo ago
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
Angius
Angius17mo ago
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
NullIntended
NullIntendedOP17mo ago
How can I compile them all into the exe?
Angius
Angius17mo ago
$singlefile
MODiX
MODiX17mo ago
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:
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
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-publish
Create 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.
NullIntended
NullIntendedOP17mo ago
Ok let me publish it
Angius
Angius17mo ago
Here's how to do it from the CLI, but the wizard should have a checkbox as well
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
Through wizard. I can't run it on my desktop by itself
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
The docs are outdated. This is my picture of deployment
Angius
Angius17mo ago
The output is bin/Publish not bin/Release And don't deploy as ClickOnce Nor to Azure Publish to folder
NullIntended
NullIntendedOP17mo ago
No good. Just tried all of those
NullIntended
NullIntendedOP17mo ago
Angius
Angius17mo ago
You're still looking into the bin/Release folder
NullIntended
NullIntendedOP17mo ago
Im sending a list of pics
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
All the pics I'm sending do not work singled out
Angius
Angius17mo ago
NullIntended
NullIntendedOP17mo ago
Yes
Angius
Angius17mo ago
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
No exe In the application files, it's all deploy files It's not giving an exe
Angius
Angius17mo ago
Idk then, try the CLI I guess
NullIntended
NullIntendedOP17mo ago
What file would I use it on? I tried it on sln and it wouldn't
MODiX
MODiX17mo ago
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:
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
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-publish
Embed Type
Link
Quoted by
From MODiX#0152
React with ❌ to remove this embed.
NullIntended
NullIntendedOP17mo ago
dotnet publish -r win-x64 BackupSystem.sln doesn't work when doing it
anita
anita17mo ago
You need to enable file extensions to see the file extension….
Angius
Angius17mo ago
Try using it on the project
anita
anita17mo ago
Setup looks like an exe to me
Angius
Angius17mo ago
Or just don't specify any file
NullIntended
NullIntendedOP17mo ago
Angius
Angius17mo ago
Just cd into the solution directory and
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true
NullIntended
NullIntendedOP17mo ago
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
Angius
Angius17mo ago
Just delete it then You can safely delete the whole bin
NullIntended
NullIntendedOP17mo ago
It has my sln in it....
Angius
Angius17mo ago
how
NullIntended
NullIntendedOP17mo ago
It requires sln
Angius
Angius17mo ago
Wtf
NullIntended
NullIntendedOP17mo ago
Yeah I'll send pic one sec dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true Ignore that
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
When I ran it in my folder it tells me this It contains only my project currently
Angius
Angius17mo ago
Means you probably made the mistake of placing your project in the same folder as the solution In that case, specify the project file
NullIntended
NullIntendedOP17mo ago
Ok dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true SPECIFY HERE?
Angius
Angius17mo ago
I think so?
NullIntended
NullIntendedOP17mo ago
Specify the sln?
Angius
Angius17mo ago
The csproj
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
The sln is the only thing I see close to that Unless u mean form1
Angius
Angius17mo ago
Because you have file extensions turned off Or maybe not?
Angius
Angius17mo ago
Angius
Angius17mo ago
Why does this not have an extension?
NullIntended
NullIntendedOP17mo ago
NullIntended
NullIntendedOP17mo ago
My file extensions is on???
Angius
Angius17mo ago
Well, that extension wasn't showing for some reason
Angius
Angius17mo ago
Now it does show
Angius
Angius17mo ago
Su, this is your .csproj file
NullIntended
NullIntendedOP17mo ago
Ohhhhh If I rename it to BackupSystem would it break everything
Angius
Angius17mo ago
Idk, it might
NullIntended
NullIntendedOP17mo ago
How can I rename it then? Properly It can't have a space in it
Angius
Angius17mo ago
Why?
NullIntended
NullIntendedOP17mo ago
Ok this is the same issue So it compiled to an exe Move exe to desktop, doesn't work. Keep in folder? Works
Angius
Angius17mo ago
Yeah, at this point I've no clue what's going on
NullIntended
NullIntendedOP17mo ago
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
Angius
Angius17mo ago
Ah, there you go
NullIntended
NullIntendedOP17mo ago
Tyvm @ZZZZZZZZZZZZZZZZZZZZZZZZZ !!!
Angius
Angius17mo ago
Anytime
NullIntended
NullIntendedOP17mo ago
My first ever c# project is now complete >:D
Accord
Accord17mo ago
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.
Want results from more Discord servers?
Add your server