Build a stand-alone executable by Visual Studio 2019 Community

Moshe Wiener 31 Reputation points
2020-11-28T20:11:56.747+00:00

I have Visual Studio 2019 Community. I try to create a stand-alone executable out of a .NET Console project. Yet, the .exe I get needs several DLLs from the VS environment. I want to run the EXE on a computer in which VS is not installed., How do I create a true self contained EXE?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,174 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Timon Yang-MSFT 9,571 Reputation points
    2020-12-01T09:56:36.76+00:00

    Are you using .net framework or .net core?

    If it is .net core, please try the following steps:

    1. Right-click on the project and select Publish.
    2. Choose the location you want to deploy, as an example, I choose the folder, and then next->finish.
      44053-1.png
    3. Click Edit, set Deployment Mode to Self-contained, expand File publish options, and select Produce single file.
      44046-2.png

    If the response is helpful, please click "Accept Answer" and upvote it.
    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.

    6 people found this answer helpful.

  2. Castorix31 81,356 Reputation points
    2020-11-28T20:55:04.217+00:00
    0 comments No comments

  3. abbodi86 3,776 Reputation points
    2020-11-29T19:40:17.417+00:00

    If you mean external or 3rd party reference assemblies, you can merge them
    https://github.com/dotnet/ILMerge
    https://github.com/gluck/il-repack

    0 comments No comments