Closed jonrmorgan99 closed 3 years ago
It's sad to hear that. You may have specified some other options when publishing. Please check with mine ClickOnceProfile.pubxml file:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ApplicationRevision>5</ApplicationRevision>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<CreateDesktopShortcut>True</CreateDesktopShortcut>
<CreateWebPageOnPublish>True</CreateWebPageOnPublish>
<GenerateManifests>True</GenerateManifests>
<Install>True</Install>
<InstallFrom>Web</InstallFrom>
<InstallUrl>http://testurl/</InstallUrl>
<IsRevisionIncremented>True</IsRevisionIncremented>
<IsWebBootstrapper>True</IsWebBootstrapper>
<MapFileExtensions>True</MapFileExtensions>
<OpenBrowserOnPublish>False</OpenBrowserOnPublish>
<Platform>Any CPU</Platform>
<PublishDir>D:\Publish\WpfSettings\</PublishDir>
<PublishUrl>D:\Publish\WpfSettings\</PublishUrl>
<PublishProtocol>ClickOnce</PublishProtocol>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishSingleFile>False</PublishSingleFile>
<SelfContained>False</SelfContained>
<SignatureAlgorithm>(none)</SignatureAlgorithm>
<SignManifests>False</SignManifests>
<TargetFramework>net5.0-windows</TargetFramework>
<UpdateEnabled>False</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateRequired>False</UpdateRequired>
<WebPageFileName>Publish.html</WebPageFileName>
<History>True|2021-08-20T14:24:00.3930048Z;True|2021-08-20T18:19:21.9714881+04:00;</History>
</PropertyGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.NetCore.DesktopRuntime.5.0.x64">
<Install>true</Install>
<ProductName>.NET Desktop Runtime 5.0.9 (x64)</ProductName>
</BootstrapperPackage>
</ItemGroup>
</Project>
Thanks for your quick reply.
Here's the pubxml I am using with my app:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.7.0</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<CreateWebPageOnPublish>True</CreateWebPageOnPublish>
<GenerateManifests>True</GenerateManifests>
<Install>True</Install>
<InstallFrom>Web</InstallFrom>
<InstallUrl>https://www.fm-alivedev.com/downloads/xym7/</InstallUrl>
<IsRevisionIncremented>False</IsRevisionIncremented>
<IsWebBootstrapper>True</IsWebBootstrapper>
<ManifestCertificateThumbprint>DF3E4EE1E682FD026FFD2AAA973FF5CACF69FA23</ManifestCertificateThumbprint>
<ManifestKeyFile>FM-Alive4.pfx</ManifestKeyFile>
<MapFileExtensions>True</MapFileExtensions>
<MinimumRequiredVersion>1.0.1.0</MinimumRequiredVersion>
<OpenBrowserOnPublish>False</OpenBrowserOnPublish>
<Platform>Any CPU</Platform>
<ProductName>XY Manager 7</ProductName>
<PublishDir>D:\FM-Alive\WebDev\Current Build\wwwroot\downloads\xym7\</PublishDir>
<PublishUrl>D:\FM-Alive\WebDev\Current Build\wwwroot\downloads\xym7\</PublishUrl>
<PublisherName>FM-Alive</PublisherName>
<PublishProtocol>ClickOnce</PublishProtocol>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishSingleFile>False</PublishSingleFile>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>False</SelfContained>
<SignatureAlgorithm>sha256RSA</SignatureAlgorithm>
<SignManifests>True</SignManifests>
<TargetFramework>net5.0-windows</TargetFramework>
<UpdateEnabled>False</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateRequired>True</UpdateRequired>
<UpdateUrl>https://www.fm-alivedev.com/downloads/xym7/</UpdateUrl>
<WebPageFileName>Publish.htm</WebPageFileName>
</PropertyGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.NetCore.DesktopRuntime.5.0.x86">
<Install>true</Install>
<ProductName>.NET Desktop Runtime 5.0.7 (x86)</ProductName>
</BootstrapperPackage>
</ItemGroup>
</Project>
I can't see any significant differences that might prevent silent install.
Any other suggestions ?
Thanks
You set UpdateEnabled. Whereas in my case this value is false. For a quiet update, you should check the version of the application on the server manually (UpdateAvailable()) and if it is different, then run the update (method Update())
My pubxml sets update enabled to false - see listing above :
<UpdateEnabled>False</UpdateEnabled>
UpdateAvailable(0 works fine as does the rest of your code. I think the problem is with the "hack" in OpenURL():
// hack because of this: https://github.com/dotnet/corefx/issues/10361
url = url.Replace("&", "^&");
return Process.Start(new ProcessStartInfo("cmd", $"/c start {url}")
{
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardInput = true,
RedirectStandardOutput = false,
UseShellExecute = false,
}
Again, I can't see anything obviously wrong but when cmd executes my browser (Firefox) opens for a manual download of the application manifest, so not a "silent" update.
Issue 10361 seems mainly concerned with how to boot the default browser not how to execute a url without opening the browser. Perhaps your ProcessStartInfo settings are meant to achieve this, but I can't see how.
Your code does what you ask: launch the browser, whereas to update a running application, you need to call the appropriate method like shown here:
Thanks, but that is exactly what my code does: as in your line 79, it calls the Update method. When an update is available, OpenURL is called but, as explained above, there seems to be a problem with the "hack". The browser boots to query download the app. manifest, so it does not silently update the app. BTW my app. is Net5 Winforms -perhaps your code is WPF specific ?
Progress ! I now have the all the code working. Although the update is not completely silent, the browser no longer shows and no user input is required.
Just one further question. After updating you advise against restarting the app
// On update don't make application restart! This is important! // Just make shutdown of current app
Is there a reason for this, rather than calling Application.Exit and then starting the updated app in a new Process ?
The Update method itself will launch a new version of the application. If you do a restart by yourself you will get an endless cycle of restarts and downloading new versions. Cheers.
Thanks for the explanation. Hopefully this thread will help others trying to fill the gap left by removing the Application.Deployment class in Net5, especially as any replacement seems unlikely before Net7. Cheers.
Thanks for posting this workaround for the missing ApplicationDeployment methods in Net5. You mention that the workaround features Silent Updates. However on my setup OpenURL(setuppath) in your Update code boots my browser and offers to download the application manifest manually. The OpenURL method throws a file not found exception which is handled by the "hack" you included.
Any idea how I can get the app to update silently ?
Thanks.