简体   繁体   中英

Windows Forms Single-File Executable

I am developing a Windows Forms project in Visual Studio 2019. My question is that when compiling the project, multiple files are generated, on which the executable is dependent. Is there a way to compile them all into a single.exe file? NOTE: I don't intend to use setup.exe: I just want a single executable that I can run from any part of my file system.

Thanks in advance.

In VisualStudio 2019 you can choose the option Publish, there you have an option to export as single file. Check this microsoft docs link for more details.

The only solution that worked for me, is the one suggested in this article

https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli

On Windows you need to navigate to the folder of the project using command prompt (an easy way to do that, is to enter the folder with File Explorer, and than typing in the address bar 'cmd'), and than typing in the command -

dotnet publish -p:PublishSingleFile=true -r win-x64 -c Release --self-contained true

You can than find the executable at project name /bin/Release or Debug/net6.0-windows/win-x64/

The release or debug folders are determined by your current project properties.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM