I am using Visual Studio 2019 to build a C# Forms application. When publishing an .exe file from a Console application, I have the option to include all the .dll files into the .exe, meaning that users of my application only need to download one file. However, when publishing an .exe from a Forms application, I'm forced to include all of these .dll files independently:
View of folder with .dll files
Is there a way to include these .dll files inside of the .exe so that I only have to send someone the .exe file for them to be able to run it, similar to how it's possible for Console applications?
EDIT: I've discovered that I was in .NET Core and should've been in .NET Framework. I'm relatively new to C# and wasn't aware of the differences. This issue is now resolved! If anyone runs into this problem, just copy-paste your code over to .NET Framework and listen to the instructions in the description.
You need to change the configuration settings during the build step to be "self-contained":
dotnet
clidotnet publish -r win-x64 -c Release --self-contained
Add <PublishSingleFile>true</PublishSingleFile>
to your project file.
On the Solution Explorer pane, right-click on the project you want to publish. Select Publish .
If you don't already have a publishing profile, follow the instructions to create one and choose the Folder target-type.
Choose Edit .
In the Profile settings dialog, set the following options:
Choose Save to save the settings and return to the Publish dialog.
Choose Publish to publish your app as a single file.
For more information, see Visual Studio Docs: Single file deployment and executable .
Duplicate of Embedding DLLs in a compiled executable
I don't think compile all files into one is a good idea. If you want to have single file for downloading, you can package them into a self-extract zip format (winRAR, winzip or 7zip). Good luck~~
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.