Shahin Dohan
Shahin Dohan

Reputation: 6932

Add shortcut to .NET 6 exe in Visual Studio Installer Project

I followed this guide from Microsoft on creating an installer project for a couple of .NET 6 projects, and everything worked fine except I'm struggling to get a shortcut into the start menu.

The way it's supposed to be done, as far as I understand, is to create a shortcut in User's Programs Menu that then points to the Primary output from ... entry in Application Folder, but according to Microsoft, instead of using the primary output I should use Publish items for .NET Core projects, so what should I then do for shortcuts?

I tried creating a primary output anyway, and then a shortcut to it, but it didn't work.

This is what my Application Folder looks like right now:

Microsoft Visual Studio 2022 Installer Project

Thank you!

Upvotes: 3

Views: 1514

Answers (2)

Meeting Attender
Meeting Attender

Reputation: 976

I had the same issue. Do not create "Primary output". Instead, create shortcut of "Publish Items from YourApp (Active)" then move that shortcut to "User's Programs Menu" and/or "User's Desktop".

This worked for me .NET 6, Windows Forms application.

Upvotes: 2

Shahin Dohan
Shahin Dohan

Reputation: 6932

All I had to do was to build the installer project, then suddenly I was able to add a new shortcut in User's Programs Menu that targeted my WPF Publish Items action, and after installation the shortcut finally appeared in my start menu.

What threw me off was the fact that Primary output types were always visible when adding shortcuts, so I thought the tool filtered them out because they were incompatible.

My publish actions do have red lines now under them, and I have no idea what they mean, but the installer and shortcut work.

The last thing I needed was "regular shortcuts", not those advertised ones that don't point to the installed EXE, to do that I had to download this vbs script to my installer project root dir and run it in the installer's post-build event like so (properties panel on bottom-right):

cscript //nologo "$(ProjectDir)WiRunSql.vbs" "$(BuiltOuputPath)" "INSERT INTO Property(Property, Value) VALUES ('DISABLEADVTSHORTCUTS', '1')"

Finally everything works!

Upvotes: 2

Related Questions