I am trying to deploy a ClickOnce application using .NET 6.0 framework where there would be a desktop icon created for the app when it is updated or installed.
When the application is installed for the first time (or un-installed and installed again...) the icon is correctly placed on the desktop - I imagine this is using the settings within the Publish section in VS2022.
The issue I am having is when the application is already installed, and now I am releasing an update which would start creating this icon to avoid having to un-install it and re-install it for all users.
I have tried using the following code, but after some research I believe the references it is using are no longer available in .NET 6.0 and are only available up to .NET 4.8.
Private Sub CreateDesktopIcon()
Dim ad As ApplicationDeployment = ApplicationDeployment.CurrentDeployment
If ad.IsFirstRun Then
Dim assembly As Assembly = Assembly.GetEntryAssembly()
Dim company As String = String.Empty
Dim description As String = String.Empty
If Attribute.IsDefined(assembly, GetType(AssemblyCompanyAttribute)) Then
Dim ascompany As AssemblyCompanyAttribute = CType(Attribute.GetCustomAttribute(assembly, GetType(AssemblyCompanyAttribute)), AssemblyCompanyAttribute)
company = ascompany.Company
End If
If Attribute.IsDefined(assembly, GetType(AssemblyDescriptionAttribute)) Then
Dim asdescription As AssemblyDescriptionAttribute = CType(Attribute.GetCustomAttribute(assembly, GetType(AssemblyDescriptionAttribute)), AssemblyDescriptionAttribute)
description = asdescription.Description
End If
If Not String.IsNullOrEmpty(company) Then
Dim desktopPath As String = String.Empty
desktopPath = String.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "\", description, ".appref-ms")
Dim shortcutName As String = String.Empty
shortcutName = String.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\", company, "\", description, ".appref-ms")
System.IO.File.Copy(shortcutName, desktopPath, True)
End If
End If
End Sub
Is there any way of carrying on deploying this application via ClickOnce and .NET 6.0 and being able to programmatically adding a desktop icon for the app or would I need to implement a different way of publishing my application?