問題描述
如何在無需重新下載每個文件的情況下更新已部署的 clickonce 應用程序? (How do I update a deployed clickonce application without having to redownload every file?)
I have an application with a database that I am running. I added all the dll's, exe's and db files I needed. These are content that are not going to be compiled. So I have set their Build Action as "Content" and their Copy to Output Directory as "Copy if newer". With this, everytime I publish a newer version of the application, I change only one file slightly, yet still all the files are redownloaded. I have looked around here and apparently there is a hash associated with all the files. But they don't seem to be giving me an answer of how I can publish a new version of an application, and have the end user only download the files that have changed?
參考解法
方法 1:
As you've noted, the files are hashed. When installing updates, ClickOnce checks the files on the server against the local version, and if they are the same, it doesn't download them again, it copies them from the local directory.
I believe this only actually works for assemblies. If you look in your ClickOnce cache, you will find that each assembly in your deployment is copied into its own folder - this is kind of like a mini-cache that ClickOnce uses, and this is what it checks against when doing the comparison.
It might happen for other resources, but I wouldn't bet on it. As noted by eoghank, you could use fiddler to verify that.
方法 2:
Are you sure the files that are not changing are being downloaded again? Use fiddler to check, the ClickOnce download dialog always indicates through the download size that all files are being re-downloaded which is not always the case.
(by Heinrich Schmidt、RobinDotNet、eoghank)