Single-file deployment not building in WPF project

Wally96333 71 Reputation points
2023-10-18T00:18:32.96+00:00

I am trying to merge all of my DLLs and other dependencies into a single file application for a WPF project. This is not a .NET Core application. I am using Visual Studio 2017 Community on a Win 10 Pro system.

Apparently, ILMerge will not work for this. After some research, I came across (what seems to be) a very simple solution.

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

I've added the following tags into my .CSPROJ file and rebuilt the application. The executable is indeed generated without any errors, but it does not contain the DLLs. I do not get an error message, so I have no idea as to what went wrong.

Any assistance with this would be appreciated.

<PropertyGroup>
    <PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>
Developer technologies | Windows Presentation Foundation
Developer technologies | .NET | Other
Developer technologies | Visual Studio | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Hui Liu-MSFT 48,676 Reputation points Microsoft External Staff
    2023-10-18T06:59:43.2+00:00

    Hi,@Wally96333. Welcome to Microsoft Q&A forum.

    If you are using Visual Studio 2017 and are trying to create a single-file deployment for your WPF.NET Framework project, you might encounter limitations.

    It doesn’t work with .NET Framework 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 or higher versions of .NET to make it work.

    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.

    For more information on single file deployments, you could refer to Single-file deployment.


    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.