Skip to main content

Once you have completed developing code for your application using Visual Studio, it is time to deploy the code to the world so that the other people could download and use your code on their computers.

Here we will learn 

  1. How to create a installation setup file that installs all the required libraries to your Computer like traditional installer 

  2. and also How  to create a stand alone exe file that runs from a folder using Visual Studio

 

This is specific for Visual Studio, You find the tutorial for creating stand alone exe file using .NET SDK here

 

Contents 

 

Visual Studio Publish Command 

To create executables that can be deployed on other peoples computers ,You can use the Publish Selection Command under the Build Menu available on the Visual Studio IDE.

how to deploy windows executable files using Visual studio

 

On clicking  Publish you will be provided with the following dialogue box

How to create stand alone windows executable files using Visual studio

 

Here you have two options for publishing your executable files.

  1. ClickOnce

  2. Folder 

 

ClickOnce Installation

Here we will learn to create a installer setup using the ClickOnce installer available in the Visual studio. 

ClickOnce is similar to traditional Next,Next type installer that we are all familiar with but unlike other installers, ClickOnce provides zero control on where your application is installed.

You can create a ClickOnce installation by Clicking on the ClickOnce button inside the  dialogue.

creating a windows installation package using ClickOnce tool in Visual studio

 

Now select the location on your disk where the installer will be created.

creating msi windows installer using click once

 

Select CD,DVD,USB as the option from where your user will install the setup file .

creating windows msi installer packages using visual studio tutorials

Select Version Number

adding version number to your executable in visual studio clickonce publish system

 

Sign Manifests, Most users can ignore this page. you can upload a digital certificate to authenticate your code and its ownership.

Now in Specify Project Configuration , 

We get to specify what sort of .NET Executable we want to create and on which all platforms the executable will run.

how to create a dotnet executable that will run on multiple platforms using Visual studio publish command

 

Here Target framework is .NET 8.0 LTS which was specified when the Windows Project was created.

Two things we need to be concerned is the 

  1. Deployment Mode
  2. and Target RunTime

 

Deployment Mode  provides two options 

How to create a stand alone Self contained dotnet windows executable msi setup file using Visual studio clickonce

 

Framework Dependent Executable is the default and it means that your executable will depend upon the .NET Platform  installed on your PC to run its Code. The executable generated by the ClickOnce will contain only your specific dependencies and some other code. This method creates an executable with really small size. One major issue is that if the correct .NET version is not installed on your system, the code will fail to run.

Self Contained Executable. means that your executable will bring its own .NET Libraries and Runtime along with your Project specific dependencies. This means that the executable do not care whether a specific runtime is installed on your Computer or not. Downside is that the executable size will be large.

 

Target Run Time.

selecting the target run time for your exe file

 

This helps to select which type of OS and Architecture your code need to run.

Once the Parameters are set you can publish the Executable  by pressing the publish button.

publishing a windows executable using Visual Studio clickonce

 

Once the Publish command had run its course, you can find the Windows Setup file inside your Publish folder.

creating a windows setup file using visual studio

 

If you run the code you will get the following Window.

You can Press Install ,to install the Application on your PC.

After installing the code, you can find the Executable in the Recently added section or in the Control Panel of your Windows PC .You can remove it from your PC using the Uninstall option.

how to uninstall a clickonce executable from your PC

 

 

Contents of the Framework Dependent Installer vs Self Contained Installer

 

Contents of the Framework Dependent Installer.

As you can see the size is small with relatively few dll files.

While the size of the self contained installer is around 171MB as shown below.

creating a self contained installation package using clickonce

It also carries a .NET runtime along with it.

 

Publishing to a Folder 

Instead of using ClickOnce we can create a single Executable and Publish it to a Folder. Here the exe file runs from the local folder without getting installed on the system.You can create the installer by clicking on the Folder icon

creating a single file executable using visual studio publish

Rest of the things are similar to the Previous one .

Select Location.

 

and finally you will get the executable.

Tags