Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve update detection for .NET (Core) applications deployed with ClickOnce #27

Open
NikolaMilosavljevic opened this issue Aug 21, 2020 · 56 comments
Assignees

Comments

@NikolaMilosavljevic
Copy link
Member

.NET (Core) applications deployed with ClickOnce cannot use ApplicationDeployment class for on-demand update check.

Besides checking for new updates, this check can be used to ensure that the deployment is still available on the server and wasn't deleted. If application is doing silent updates, without this check, user won't be aware that application is not getting any updates.

Launcher could do the update check if application is configured to install new updates automatically. We need to find a way to communicate the result of this check to .NET (Core) application. We could potentially also include the result of any recent automatic update.

@Rmurray0809
Copy link

Would there be any reason ClickOnce couldn't just drop a JSON file with information into the application directory when it is started? It seems like this would allow an easy way for the application find out information about the install (ie put the version thats on the server, the install URL etc). It could have extra information in it that would allow the developer to take action based on the information (exceptions?). This would also make it fairly extensible so if someone wanted to add information in the future they could and generally applications will just continue to work.

@NikolaMilosavljevic
Copy link
Member Author

@Rmurray0809 yes, a similar approach is considered - we'll have more details on the design soon.

@TimKras
Copy link

TimKras commented Jan 28, 2021

Any updates about this?

@NikolaMilosavljevic
Copy link
Member Author

@TimKras thank you for the interest in this feature. We don't have an estimate, yet, when it would be available as a preview.

cc @dleeapho

@derskythe
Copy link

For those people who want to use ClickOnce on .NET 5 and want silently update, I wrote a small wrapper that implements some of the ApplicationDeployment properties:

  • CurrentVersion
  • ServerVersion
  • UpdateAvailable
  • Update
  • IsNetworkDeployment
  • DataDir

Hope this helps someone: https://github.com/derskythe/WpfSettings

@greatoceansoftware
Copy link

I definitely need the functionality of ApplicationDeployment. I can't seeing declaring victory of bringing ClickOnce to .NET 5/6 without it.

This is mainly because the limitation of only checking at application startup is annoying for most users. It's funny that they don't mind a splash screen with loading progress, but they mind this. Mainly because they want update checking AT THEIR CONVENIENCE. And I agree in the case of most of my applications.

Thanks for any consideration. Without it, it's back to commercial installers.

@jonrmorgan99
Copy link

Totally agree - without in-app updating ClickOnce is neutered. MSIX is not a real world alternative at present. Under NetFX ClickOnce proved it's reliability which is presumably why it made the cut to .Net5/6.

So please re-open this issue and let's have a progress update. Thanks.

@luronumen
Copy link

Unable to port WinForms project from .NET Framework 4.8 to .NET 5.0 due to the following issue:
CS0234 - The type or namespace name 'Deployment' does not exist in the namespace 'System' (are you missing an assembly reference?)

@jonrmorgan99
Copy link

@derskythe

For those people who want to use ClickOnce on .NET 5 and want silently update, I wrote a small wrapper that implements some of the ApplicationDeployment properties

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. Any idea how I can get the app to update silently ?

Thanks.

@alansingfield
Copy link

If you just need an "Update Now" button in your app, you can shell out to this command and then exit.

rundll32 dfshim.dll,ShOpenVerbApplication http://yourupdateurl/yourapp.application

@Mrxx99
Copy link

Mrxx99 commented Nov 5, 2021

This is on the 6.0 milestone, so will this be fixed until next week?

@DDD25583
Copy link

I just tried to migrate a net4.8 app to .NET 6 when I came across this issue.
Being able to get the CurrentVersion is crucial in are error and bug-processing procedures.
As the production environment contains a lot of computers, updating (close and restart) an app is done once in the 24 hours.
So it is important that we know on which version of the app, an error is thrown.

@simmotech
Copy link

Based on ideas/code from @derskythe, @alansingfield, @e-master, I created a repro at https://github.com/simmotech/Net6ClickOnce which passes through all the info from args/ApplicationDeployment/ActivationArguments to the .NET 6 ClickOnce app. It also allows in-app detection of any later version and updating to that version on close.

Might be worth a look to use until an official fix is made. Grateful for any suggestions/further testing.

@jonrmorgan99
Copy link

Great to see ClickOnce in Net6, but still no progress on restoring the in-app updating functions in Application.Deployment.

Is there any update on this issue ? Net 7 maybe ??

@raffaeler
Copy link

@NikolaMilosavljevic Do you have any news for this?
We are still stuck since #9 (comment)
This really prevents the migration of a large number of applications.

@NikolaMilosavljevic
Copy link
Member Author

@NikolaMilosavljevic Do you have any news for this? We are still stuck since #9 (comment) This really prevents the migration of a large number of applications.

We are definitely tracking improvements in ClickOnce experience for .NET (Core) apps, for upcoming release. You can expect to see some designs published in the next several weeks. Improvements might be brought up in stages, to allow for a better design and experience, as well as more testing with early previews.

@khaheldev
Copy link

Hello! Will this be available on .NET 7? Thanks!

@NikolaMilosavljevic
Copy link
Member Author

The work to expose properties of ApplicationDeployment class to .NET app is happening right now. It will be available soon, in one of our Previews, during .NET 7 development. Please note that dotnet-mage ships as .NET Global tool and not as part of .NET release (i.e. 7).

@UFuz
Copy link

UFuz commented May 9, 2022

If you just need an "Update Now" button in your app, you can shell out to this command and then exit.

rundll32 dfshim.dll,ShOpenVerbApplication http://yourupdateurl/yourapp.application

@alansingfield : With original .Net4.8 update mechanism, I used to run
ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;
updateCheck.Update();
show a success messagebox;
Application.Restart();

with the "dfshim.dll" approach I have 3 issues:

  1. it returns immediately, not waiting for the update to complete
  2. application.restart will relaunch the old version, instead of the new
  3. restarting by desktop icon does not maintain the application settings, so app starts with defaults

Is there a way to improve this, especially point 3?

@heku
Copy link

heku commented Oct 13, 2022

except the issue discussed above, I have another question, anybody know why a .net 6 WPF application with "online" mode only, cannot update itself when a new version published?(the application is not signed, but I didn't see any doc says update detect needs sign)

@NikolaMilosavljevic
Copy link
Member Author

except the issue discussed above, I have another question, anybody know why a .net 6 WPF application with "online" mode only, cannot update itself when a new version published?(the application is not signed, but I didn't see any doc says update detect needs sign)

@heku was the application built using dotnet-mage or ClickOnce publishing in Visual Studio?

cc @sujitnayak @John-Hart

@sujitnayak
Copy link

@NikolaMilosavljevic The VS ClickOnce behavior in .NET 6.0 apps is consistent with .NET 4.X. Update is not enabled if app is Online only.

@heku
Copy link

heku commented Oct 13, 2022

@sujitnayak visual studio, it is totally different as my expectation, I thought Online mode means always “latest”, if so, what the purpose of Online mode?

@heku
Copy link

heku commented Oct 14, 2022

@John-Hart Thx, I saw the doc before, it only says the difference of online/offline is online needs access to publish location, never mentions any difference about update behavior

@sujitnayak
Copy link

Behavior of auto-update not being available in online-only mode is not new to .NET 6.0 apps. .NET 4.X apps have had the same behavior as you can see in the screenshot attached:

image

Auto-update is for apps that are installed locally on the machine (visible in Add Remove Programs and Start menu) which happens only when offline mode is also available for the app.

@heku
Copy link

heku commented Oct 15, 2022

@sujitnayak ok, the "updates" button is disabled for Online mode, I thought it means Online mode app is always up to date, that what I really misunderstand. since it has same behavior as .NET Framework, I have no question any more, thank you.

@LeDahu22
Copy link

LeDahu22 commented Nov 9, 2022

The work to expose properties of ApplicationDeployment class to .NET app is happening right now. It will be available soon, in one of our Previews, during .NET 7 development. Please note that dotnet-mage ships as .NET Global tool and not as part of .NET release (i.e. 7).

Any update on this ? .Net 7 was released yesterday yet ApplicationDeployment class is still unrecognized. Do we need to install something else in order to get this working ?

@NikolaMilosavljevic
Copy link
Member Author

ClickOnce support for .NET ships separately from main .NET (i.e. .NET 7). It ships as a global tool. We will be releasing version 7.0.0 of dotnet-mage in the next few days.

This feature is available in our preview release: https://www.nuget.org/packages/Microsoft.DotNet.Mage/7.0.0-preview.2.22317.2. For all previews you'd need to specify explicit version number, to install it, following the steps for the tool installation from the doc page: https://github.com/dotnet/deployment-tools/tree/main/Documentation/dotnet-mage

Please note that this feature is already available in Visual Studio 2022 build 17.3 or later.

Here's the relevant PR with more details about this feature and some examples: #208

@tejs-code
Copy link

@NikolaMilosavljevic Is there an alternate to UpdateAsync, a way to install the update in the backgroun? I understand the app has to be restarted anyway, but it provides a way to download and process update in the background without paying a cost on open and showing a dialog to the user whether to install the update or not.

@TimKras
Copy link

TimKras commented Nov 10, 2022

@NikolaMilosavljevic
How should this feature used in an application.
Do we need to read the Environment.GetEnvironmentVariable("ClickOnce_IsNetworkDeployed") manually, or will there be a wrapper? Or should we use this class in our application: https://github.com/dotnet/deployment-tools/blob/dfb0a98c68da39fc9cd1d82e200a19badf4e7112/Documentation/dotnet-mage/ApplicationDeployment.cs

@NikolaMilosavljevic
Copy link
Member Author

@NikolaMilosavljevic How should this feature used in an application. Do we need to read the Environment.GetEnvironmentVariable("ClickOnce_IsNetworkDeployed") manually, or will there be a wrapper? Or should we use this class in our application: https://github.com/dotnet/deployment-tools/blob/dfb0a98c68da39fc9cd1d82e200a19badf4e7112/Documentation/dotnet-mage/ApplicationDeployment.cs

Yes, at the moment, those would be the only 2 solutions. You could use that sample wrapper class or create a new own. Reading environment variables would also work, if you only need to use a few.

@NikolaMilosavljevic
Copy link
Member Author

@NikolaMilosavljevic Is there an alternate to UpdateAsync, a way to install the update in the backgroun? I understand the app has to be restarted anyway, but it provides a way to download and process update in the background without paying a cost on open and showing a dialog to the user whether to install the update or not.

There is no alternative today, for silent update, which was provided by UpdateAsync in the past (for .NET FX apps). That experience requires running update in the app context, which isn't possible today as System.Deployment library is not available in .NET.

We understand that this is an important scenario for some applications and will be looking into ways to close this gap in experience.

@luronumen
Copy link

Hi @NikolaMilosavljevic

I noticed that the ApplicationDeployment.cs class still missing the 2 methods that are available on ClickOnce for .NET 4.8 Framework:

  • CheckForDetailedUpdate()
  • Update()

Is there any plan to implement them or any alternative methods to them on .NET 7.0?

Thanks in advanced,
Luciano

@NikolaMilosavljevic
Copy link
Member Author

Hi @NikolaMilosavljevic

I noticed that the ApplicationDeployment.cs class still missing the 2 methods that are available on ClickOnce for .NET 4.8 Framework:

  • CheckForDetailedUpdate()
  • Update()

Is there any plan to implement them or any alternative methods to them on .NET 7.0?

Thanks in advanced, Luciano

That is correct. The sample class adds support for obtaining properties and does not have any methods related to updating the app. We understand that this is an important scenario for some applications and will be looking into ways to close this gap in experience.

@luronumen
Copy link

That is correct. The sample class adds support for obtaining properties and does not have any methods related to updating the app. We understand that this is an important scenario for some applications and will be looking into ways to close this gap in experience.

Thank you very much for your prompt reply @NikolaMilosavljevic !
Are these gaps planned to be resolved in .NET 7.0 or will they only be available in .NET 8.0?

Thanks again!

@NikolaMilosavljevic
Copy link
Member Author

Those features are not planned for 7.0, which GA'd last week. dotnet-mage, which will GA in a day or two, always support building deployments for older .NET versions, unless that is not feasible. For instance, new features that we add in dotnet-mage version 8 would support .NET 8.0, and all previous .NET releases.

@jonrmorgan99
Copy link

Hi @NikolaMilosavljevic

Just following up @luronumen and your response:

I noticed that the [ApplicationDeployment.cs](https://github.com/dotnet/deployment-tools/blob/dfb0a98c68da39fc9cd1d82e200a19badf4e7112/Documentation/dotnet-mage/ApplicationDeployment.cs) class still missing the 2 methods that are available on ClickOnce for .NET 4.8 Framework:

    CheckForDetailedUpdate()
    Update()

Is there any plan to implement them or any alternative methods to them on .NET 7.0?

Thanks in advanced, Luciano

That is correct. The sample class adds support for obtaining properties and does not have any methods related to updating the app. We understand that this is an important scenario for some applications and will be looking into ways to close this gap in experience.

Has there been any progress in restoring methods for updating ClickOnce apps ? Is there a timeline to include them in .NET 8.0 ?
Is there anything the user community can do to help ?

Thanks for continuing to develop ClickOnce !

@mike7ang1rdz
Copy link

ClickOnce support for .NET ships separately from main .NET (i.e. .NET 7). It ships as a global tool. We will be releasing version 7.0.0 of dotnet-mage in the next few days.

This feature is available in our preview release: https://www.nuget.org/packages/Microsoft.DotNet.Mage/7.0.0-preview.2.22317.2. For all previews you'd need to specify explicit version number, to install it, following the steps for the tool installation from the doc page: https://github.com/dotnet/deployment-tools/tree/main/Documentation/dotnet-mage

Please note that this feature is already available in Visual Studio 2022 build 17.3 or later.

Here's the relevant PR with more details about this feature and some examples: #208

are you guys not releasing a non preview version to a LTS NET version?. We are currently releasing to NET 6 and due to short-term support not releasing to NET 7.

you should also target to NET 6 because it is LTS.

@mike7ang1rdz
Copy link

Hi @NikolaMilosavljevic
I noticed that the ApplicationDeployment.cs class still missing the 2 methods that are available on ClickOnce for .NET 4.8 Framework:

  • CheckForDetailedUpdate()
  • Update()

Is there any plan to implement them or any alternative methods to them on .NET 7.0?
Thanks in advanced, Luciano

That is correct. The sample class adds support for obtaining properties and does not have any methods related to updating the app. We understand that this is an important scenario for some applications and will be looking into ways to close this gap in experience.

CheckForDetailedUpdate
this method is stopping me any workarounds available like calling service directly?

@statler
Copy link

statler commented Mar 28, 2023

Hi @NikolaMilosavljevic

Any update on the support for methods from the ApplicationDeployment class? Or somewhere there is a proposal we can track for this? I understand the technical challenges with the .Net/Core changes compared to framework, but surely there is a way...

@JDA88
Copy link

JDA88 commented Jul 19, 2023

This issue (and the lack of workarounds) is preventing us to migrate to .NET7

@berets76
Copy link

berets76 commented Aug 9, 2023

Could we just have an idea of if/when this functionality will be restored?
This is a very important feature in some applications, we have been stalling for months, but now we need a certain time target.

Please just say yes or no, so we can possibly take other ways.
If it won't even be present in version 8, we will necessarily have to find an alternative.

Thanks

@NikolaMilosavljevic
Copy link
Member Author

There are no immediate plans to add official support for in-app update functionality. There are some, perhaps less-than-ideal workarounds, provided in the comments of this issue. It is worth exploring and fine-tuning those options today.

.NET applications can access Application deployment properties using methods described in this PR: #208

Besides here at GitHub, I would also suggest voicing these and similar requests through Developer Community site: https://developercommunity.visualstudio.com/home

@fatih252
Copy link

Hello @NikolaMilosavljevic , any update or possible planning yet to support the extra methods ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests