Deployment of self-contained applications with Visual Studio Community 2022

mauede 221 Reputation points
2022-01-23T13:06:58.227+00:00

I am working with a hospital group dealing with clinical trials.
My task is to develop C# scripts to automate the time-consuming and repetitive procedures.
I avail myself of Visual Studio Community 2022.
167544-published-stuff.png
At present, I am struggling with deploying a self-contained Console Application through Visual Studio.
My code works when started from Visual Studio with and without the debugger.
Visual Studio builder dumps a lot of files in the folder where the solution and project files are found.
Among such files, there is an executable called ConsoleApplication that does work. However, it doesn't work if I separate it from all the other files. For instance, if I copy just ConsoleApplication to another folder. It is clear that the executable needs all those files to run.
However, when I publish the code using the Visual Studio "publish" facility, it only creates three items in the destination folder (see attachment).
File "ConsoleApplication" is a "manifest" and does not work when run.
Folder "application Files" contains many files among which a file called "ConsoleApplication" works when run from the folder containing all the resources it needs.

My question:
Is it possible through Visual Studio to publish one self-contained file that contains all the necessary run-time environment? Instead of merging the executable with a raft of other files that confuse the users who laymen users?

Thank you in advance for your attention.

Regards,
Maura
email: maura.monville@Stuff .com

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,306 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jack J Jun 24,296 Reputation points Microsoft Vendor
    2022-02-07T02:35:47.157+00:00

    @mauede , Sorry for the late response, based on my research, I find the problem. You could refer to the article Single file deployment and executable.

    The article describes the following sentence:

    This deployment model has been available since .NET Core 3.0 and has been enhanced in .NET 5. Previously in .NET Core 3.0

    Therefore, .NET Framework app can not make the single file currently.


2 additional answers

Sort by: Most helpful
  1. Karen Payne MVP 35,196 Reputation points
    2022-01-23T15:39:38.287+00:00

  2. mauede 221 Reputation points
    2022-01-23T20:27:34.617+00:00

    Following the guidelines in the section "Publish a single file app - Visual Studio" on
    https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file

    I opened the project file with NotePad. I added the statement <PublishSingleFile>true</PublishSingleFile>.
    The result was that Visual Studio did no more load the solution file. It printed an error message stating that statement is not recognized (attached screenshot).
    When I right-click on the project name in the solution explore pane I see this window (attached screenshot). There is no Edit option.

    How can I create a Publishing Profile?

    Thank you

     Maura  
     email:  maura.monville@gmail.com  
    

    167527-screenshot-2022-01-23-at-195633.png167585-screenshot-2022-01-23-at-202051.png

    When I right-click on the project name