question

krishna-5407 avatar image
0 Votes"
krishna-5407 asked TianyuSun-MSFT answered

WPF Publishing application into single exe file

Hi,
I have a wpf application running on VS2017 ,.net framework 4.7.2 .I want to deploy the file and have a single exe in the end and also have .net framework install into client pc if it is not installed .

I tried editing .csproj file for it and added entries

 <PublishSingleFile>true</PublishSingleFile>
     <SelfContained>true</SelfContained>
     <PublishReadyToRun>true</PublishReadyToRun>
     <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>

and saved ,then published the application using VS2017 .However i do not get a single exe file ,but a bunch of files which were there when i used to publish before without the above changes in .csproj file

vs-msbuild
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TianyuSun-MSFT avatar image
0 Votes"
TianyuSun-MSFT answered

Hi @krishna-5407 ,

Welcome to Microsoft Q&A forum.

It doesn’t work with .NET Framework 4.7.2 based projects. According to this thread: Publish a single file app does not create a single file and this link(.NET 5), you may need to use .NET 6 Preview or higher versions of .NET to make it work.

BTW, based on my test, by using .NET 6, if you choose framework-dependent to publish, you will get two files(.exe, .pdb). If you choose Self-Contained to publish, you will still get some(not a single file) files. I suggest you post this question on GitHub – dotnet if you change to use .NET 6 but get the same issue.

Best Regards,
Tianyu


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.