Validate Download process - c#

"Idea to update the new version of application on client machine"
I have read binary data from DB server using WCF, create a zip file with contents, extract the files and update our application bin folder.
I want to validate the process like if everything is fine then update bin or rollback old file.
Can anybody give me idea to validate this process?
Do we have any check sum idea..

Well if you use SharpZipLib to inflate the zip file, there is a TestArchive method on the ZipFile object that will do an integrity check of the archive, and tell you if it's valid.
Otherwise, you can use MD5 to make a checksum on the remote file, and compare it to the downloaded file to see if the content is the same.

Store on the server/web the most recent version of the project that is online. eg: in a version.txt the value "2.1.0", or query the database if you have access too.
Your application running on clients, will periodically read the contents of the version.txt file, then compared against the inbuilt(self) version number.
If a patch or minor release is detected eg 2.1.123, spins out a second app(updater.exe) that will quietly
do the upgrade,
it shall download the updated(preferred zipped) project from server/web.
Stop any running instances.
Unzipping the content.
Backup existing files(rename)
copy/install the new version of the project,
Start the application (when the app is restarted successfully it will delete its own backup file).
if a major release is detected eg: 3.0.0
notifies the user there is a major upgrade
if user accepts, download the installer
runs a full installer update
Does this help?

Related

Correct way to implement auto-update for Android app built with Xamarin.Forms

I recently started building my mobile application using cross-platform Xamarin.Forms toolkit and I'm having a hard time trying to implement some sort of an auto-update mechanism for it.
More particularly, my app has some XML files along with images stored in assets folder, all packed up in the apk file, published to the Google Play.
What I want is to edit and update those xml and assets without publishing a new version of apk in the play store. But I also know that once packed into an apk, these resources cannot be changed unless the user manually downloads and updates the app via the store.
So I currently use the following work around:
I put all of the stuff like XML files or images that I want to update on my server then make an API for specifying their version as well as providing downloadable items.
Inside my app, I have a value representing the current version of the assets. Whenever the app starts, a background process will call the server's API and check if this version value matches the one on the server.
If the versions to not match, the service will automatically download the stuff from the server and store inside user device's internal storage.
Then the app will replace local resources with the resources from the server.
The problem is that this work-around of mine is too clumsy and hard to implement. Any ideas that can help me with a cleaner or more proper solution?
Your logic is correct... if you are "versioning" assets outside of the APK, you need to track a "version" of the local assets vs. the server|remote-based assets and download/cache new assets when the remote assets are newer...
You could use APK expansion (*.obb) files to bundle your "assets" separate from your .apk bundle. But anytime you need to change an .obb (even if it is a patch-based .obb) the application version has to change and thus you have to upload an .apk with a new version to the store even if nothing else in it has changed.
re: APK Expansion Files
The new .aab format (the .apk replacement) allows you to modify individual components of the application and thus the user get a true delta of the differences of what they have installed vs. the new changes resulting in very small update sizes. Again like an .obb, the app's version needs to change and thus a new .aab has to be uploaded.
Note: Xamarin does not currently support direct building of .aab bundles (like Android Studio does), but they can be "handmade" from the MSBuild artifacts.
re: Android App Bundles
Personally for scenarios like yours, I just use a single versioned .zip that includes all the files that can dynamically change between application level version|releases and thus only track that single file (unzipping into local app cache upon download). An version file (or just a file-hash) on the server contains the latest version and URL of the zip file and the zip file itself contains a matching version file. No cached files, download and unzip the file. Upon app update check, compare the version file in the cache to the server version and download/unzip if needed. (Note: I do not even use a separate "semantic version", I just use the SH1 hash of the zip file).

Update app from the application

I am trying to develop a feature in my app, which will enable users to check for the updates and, if new version exists (on the FTP server), it will download all the new files and run the new instance of the application.
I have successfully managed to check for an update (by comparing XML files) and downloading the zip file from the FTP server into a temporary folder. However once I started copying the files into the main folder, application suddenly crashed becuase all the dll's I have tried to copy were already in use.
I came with two approaches that are possible:
1) rename all the files under the main folder to: originalname.dll.bak (append .bak to the end of their name). Then copy original files and restart application. Upon opening new instance (updated exe file), the very first thing we do is that we erase old files ending with .bak. One problem with this approach is, that I can easily rename currently running process to include .bak, yet I am not sure if I can do the same with the dll files (have not implemented this solution yet)
2) Create an external app (e.g. console app), which will be executed from the main application whcih will handle the update process. Upon opening this external updater, my main app will immediately close so that we can assure that copying of the new files will be without a problem.
I have not done any of this before therefore any comments & suggestions will be more than welcome. Also shall shall there be any better way how to handle the update process, I would be more than happy to implement it.

create self extract file from folder on server ASP.NET C#

i need it to be self extract file and after the user downloads the file to his computer and run the EXE file the installation of the software starts automatically. as can be done with WINZIP and WINRAR.
I tried to use:
http://sevenzipsharp.codeplex.com/
and could not succeed.
I know i can do it with "dotnetzip" but from what I understand it need .net 2.0 for the self extract EXE file and i do not want to be dependent on .NET framwork.
You can use a batch command to create the file and check the output for success or failure. Just use a compiled standard version of 7zip and then run the command:
"7z.exe" a -t7z -m0=LZMA -mmt=on -mx5 -sfx7z.sfx -wc:\ParetnDirectoryOfFolder D:\MyNewSelfExtracting.exe D:\Users\Martyn\FolderToBeZipped
Once you have confirmation, you can store the details in a database for retrieval later, or how ever you want the interface to go.
Sorry it's not a coded answer, but from the looks of it, you are very close to completing!

Linq To Sql update mdf file using clickonce

I have a application that use Linq2sql and have a database (mdf file). I using clickonce to release the application. I need to make changes in the database structure, How can i do this and update the mdf files using clickonce without losing the data at the files?
If you place your mdf in the data directory then you can have access to that previous-version-mdf-file when the newly installed version is run for the first time, since old data files are accessible in a PRE directory.
So at that moment you can copy the data from the old mdf to the new mdf.
To give you the full picture, are data files are renewed when a new installation is done. Its up to you to copy any old data.
Link which explain the first run of a clickonce installation:
How do I detect the first time a ClickOnce-deployed application has been run?
Link which mentions the PRE data directory to access files from the previous version.
clickonce - does writing/reading to the Data Directory required Admin rights?

how to handle temporary files/folders of VS setup project?

Still learning create MSI installer with VS 2008 for our C# application. We have some batch files to create database and tables, after installation we want to delete it because there are sensitive information on them (username, password, ...). My questions are like those:
where should I put those temporary folders/files? (doesn't matter?)
how to delete them after installation? or how to call batch file from installer? I was able to add a custome action to modify app.config file but call batch file should be a different way. (simpler than having a installer class?)
how to guarantee those files will be deleted even something wrong during the installation?
thanks,
Instead of a batch file, which anyone can open and read, consider compiling the sensitive information and commands into an .exe. If you store information in a file on someone's PC, you cannot guarantee they will not copy and retain it.
Ideally, temporary folders and files get installed in the windows temp directory, but you can also install them in your application directory.
You can't guarantee the install will complete or files will get deleted, but you can do the delete (or whatever) as early as possible so they can't install without that deletion, or you can have your app or some other process complete the deletion after the install.

Categories

Resources