DEV Community

Olabamiji Oyetubo
Olabamiji Oyetubo

Posted on

How to create an Installer for a Winforms application using ClickOnce for Visual Studio 2022

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

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, 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

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

The publish wizard modal shows up.

Publish Modal

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

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

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

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

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

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

Configure Password

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

And then click Finish.

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

Publish Application

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

Setup Installer Created

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

Happy coding everyone.

Top comments (0)