News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Creating an installer for a Windows application

Started by kcsl, Oct 18, 2025, 09:44 AM

Previous topic - Next topic

kcsl

Not directly PIC related but I thought I'd post this in the hope it helps somebody out.

For my current project, I've created a CAN BUS bootloader for a PIC and there is a related Windows program that supports the transfer of code files from the PC to the PIC.

My go to Windows programming language has always been VB6 but this time, it wasn't an option (it had to be a 64 bit Windows application as USB to CAN drivers weren't easily usable from 32 bit languages).
I elected to use VB.NET 2022 and it was a good opportunity to learn this new-fangled programming language.
I've created a decent application that does everything that's needed and I've gotten a good handle on VB.NET.

I was however blind-sided when it came to creating an installation package for my new .NET application.

In VB6 it's a piece of cake. There is a Package and Deployment wizard that scans your project, automatically includes everything you need, bundles it all up and away you go. Takes 10 minutes.

Not with Visual Studio however. You have to download the Setup plug-in and it doesn't know how to scan your project so won't automatically include everything. There are some commercial solutions that are expensive, and there was a shareware one I found but it's still really tedious to do.

Now I'm no expert on this, but you can ship your application including everything it needs; specifically the correct version of the .NET runtime, or you can have it so that the the user must have already installed the correct .NET runtime.

I went around in circles for several days. There are tutorials on YouTube that all seem to say exactly the same thing. These are great for a simple application that displays a button, but anything like a real application, they were not helpful.

After some research and experimentation, it turns out there is a setting on the VS project "Debug or Release". It defaults to Debug, but if you change it to Release, re-build the project, in your project folder there will be a \bin\release folder and if you drill down there a bit, you end up at a folder called win-x64.  This has everything you need for your project to run. If you copy this folder and drop it into the target computer, your project will run. The folder contains everything including the correct version of .NET so does make it quite large; my folder is around 250mb but these days that seems to be nothing.

So all I needed now was a nice way to package that folder up (mine has 472 files in various sub folders) and then unpack it on the users PC.

WinRar to the rescue.

I always thought this was just a compress/decompress tool, but it is so much more.

I created a folder, MyApp
In MyApp I dropped in some folders that contained a user guide, some text files and other files that I wanted to ship with my product. I then copied in the win-x64 folder.
Start WinRaw and select the MyApp folder, right click and select Add files to archive.
On the right you will see a tick-box "Create SFX archive"

After this you can just go through the options and experiment.
It will create you a fully functional self installing package with splash screen and your own logos, licence screens, desktop shortcuts with icons, all sorts of things.

When you click OK, it creates a single executable that contains everything you've selected, and places a stub at the start so that the user can just click and run the executable. It will then guide them through the installation.

It has it's limitations, but it's a very powerful tool, and it came with a free 40 day licence so I could fully evaluate its suitability. £42 for a fully licenced version.

It's saved what remaining hair I have left.

Joe





There's no room for optimism in software or hardware engineering.

shantanu@india

Hi Joe,
Thanks for this detailed writeup on VS22 which I also intend to learn in near future.
I use LabVIEW 2015 for the last 10 years which has never failed me. But I need something cross-platform , language independent & generating code for any target like Windows , Linux , Android etc. Obviously nothing can beat Visual Studio!
How is VSCode ?
Regards
Shantanu

kcsl

Shantanu,

I use VSCode all the time along with the plug-in for Positron BASIC written by Atomix, and it's brilliant.
It's also pretty close to Visual Studio so many of the quick key combinations (F12 to jump to a function definition) are the same.

Regards,
Joe
There's no room for optimism in software or hardware engineering.


Stephen Moss

Quote from: kcsl on Oct 18, 2025, 09:44 AMIn VB6 it's a piece of cake. There is a Package and Deployment wizard that scans your project, automatically includes everything you need, bundles it all up and away you go. Takes 10 minutes.
If you are using the free community edition I think they hide that away as their thinking is that generally you would not not to create a deployment method unless you were selling it as for internal use within you company there are other way of installing it.

Quote from: kcsl on Oct 18, 2025, 09:44 AMNow I'm no expert on this, but you can ship your application including everything it needs; specifically the correct version of the .NET runtime, or you can have it so that the the user must have already installed the correct .NET runtime.

I went around in circles for several days. There are tutorials on YouTube that all seem to say exactly the same thing. These are great for a simple application that displays a button, but anything like a real application, they were not helpful.
I found this page that explains how to pack everything into a single file. It indicates .Net5 but as Visual Studio no longer does anything not 64-bit or at least .Net6 it still generally seems to work even though I am now setting to use .Net8.

Generally it seems to work and produce a self contained single file, except that...
  • Depending on what Project references and Nuget Packages are installed/used, I found that Trimming sometime throws errors, so I tend not to use that option, and
  • I have had some problems with it in that for some reason it would not pack my audio files in with everything else, and when using VLC as the player for the audio file playback (using the WMP interop was fine when running in the IDE for Debugging but was baulked at when compiling for Release) I found that the output would include the VLC .DLL files if I did not include the Native libraries, but not if I did include them, which seems odd and the missing VLC .dll files resulted in errors when the program was run. But maybe I was not embedding them as a resource correctly even though I use the same method as the .RTF files and they were fine.
    So it was somewhat annoying that I could not get both the audio files to play and pack in .Net8 dependencies so the end user does not then have to have .Net8 installed to run the program (I believe .Net8 then gets unpacked into and use from RAM).

It is not clear on the page I linked to but you have to copy and past the commands given into the Developer power shell and execute them from there (Select Terminal from the View menu).