How to create an Installer for a Winforms application using ClickOnce for Visual Studio 2022
Tags: webdev, csharp, dotnet, programming
Published: 2024-05-23 23:16:58

In this tutorial, we’ll look at creating an installer for a Winforms desktop application using ClickOnce that we can share with people.

**Prerequisites:**
The only prerequisite for this tutorial is Visual Studio Community edition, go ahead and download the installer [here](https://visualstudio.microsoft.com/downloads/)

After downloading, go ahead and install and open Visual Studio.

Next, we want to create a project, we will create a small Winforms application for this demo.

I have created a Winforms application in a previous post [here](https://dev.to/bigboybamo/how-to-create-an-installer-for-a-winforms-application-using-visual-studio-2022-installer-project-5nh), you can follow that link, create your application and then come back here.

Alright, now the first thing we want to do is create the folder that will hold the installation files, so go ahead and create a folder for that. I am creating a file on my desktop called  **publish**.

![Create Publish File](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/inl24uln34dxqj9ievtx.png)

Next, we will try to build and publish our application. So from the top pane in Visual Studio, click on build and then click on **Publish Selection**

![Publish Selection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dor4ooansddoxt878nbe.png)

The publish wizard modal shows up.

![Publish Modal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hap0ekdopocspqonl3i6.png)

Then select **ClickOnce** and click Next.

After that, In the **Publish Location** field, enter the location of the folder we created earlier. I created mine on the desktop, so I will enter that and click Next

![Specify Publish folder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u15265h758pflxd6ndos.png)

Next, we're asked to specify how users will install our application. Click on the **From a UNC path or file share** option and specify the location we have created but with your computer name Appended at the front. Like so

![Install location](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m8cmxmag75altm2yup57.png)

After clicking next, we have the page where we can add any application files, specify  prerequisites our application needs to run, and configure if we want the application to check for updates

![Publish Settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qy2r1pggznh2xe7v30f.png)

Let's specify how we want to make the application check for updates.

Click **Update settings**. By default, our application is set to update before the application starts. We will leave it as it is. 

![Update Settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mhnracsvlz6ov0uld3sg.png)

Click **Ok** and Click Next.

Next, we will need to configure signing the ClickOnce manifest. 

So make sure the **Sign ClickOnce manifests** option is checked and click **Create test Certificate**


![Create Test Certificate](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vdnq7xun4ov9jhyyrrtz.png)

Then enter a strong and secure password to use to create the Temporary Key


![Configure Password](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u9an6vxnuqkh3fv29nlu.png)

Click **Ok** and click Next.

Finally, we are going to specify our project configuration information. We will leave this as it is, but you can change the Configuration, target framework, Deployment mode, and Target Runtime to what you'd like depending on your use case.


![Project Configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pyq8lic8qxb6b68ovt3f.png)

And then click Finish.

Our ClickOnce profile has now been specified. Simple Click on **Publish** to start building our installer.


![Publish Application](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lyjbeo8k9s6qh47l74sl.png)

After successfully Publishing the application, navigate to the folder we created earlier, where we specified our installation files to be created,


![Setup Installer Created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l54n8gkoetqkll2xswt7.png)

Our installer has been created, you can go ahead and run the `setup` or `SetupInstallerTutorial` file to install the WinForms application.

Happy coding everyone.