WPF Publishing application into single exe file

krishna 466 Reputation points
2022-09-01T10:36:58.173+00:00

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

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,929 questions
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 27,106 Reputation points Microsoft Vendor
    2022-09-02T05:38:34.983+00:00

    Hi @krishna ,

    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.
    0 comments No comments

0 additional answers

Sort by: Most helpful