I created a custom installer a bit ago and it works fine but I am having a few issues with it.
Unlike a package installer it is by far slower at installing.
This is how the installer works:
1. It deletes all the temporary files on the computer in case the installer was previously installed
2. Then the installers moves a .zip file to the users computer from the resources folder
3. After which it extracts the .zip (I use DotNetZip library for thus)
4. Then it moves the files it extracted to the correct director(y)(ies)
5. ...and finally it just deletes the .zip and the extracted folder off the computer
I have used installers before their job in around 5 - 7 seconds.
They move the same files as mine, but my installer that was custom made by me does the same exact job in around 40 seconds or so on my computer... For the users, it could last for up to 3 - 4 minutes.
I wouldn't be so annoyed by this fact, if not one factor... The files that the program deals with is only worth 40 - 50MB which is basically nothing.
...So I was thinking, how do they do that? Maybe there is a way for me to avoid moving the .zip and unpacking it.
Is there a way I could possibly place the already extracted folder into my Resources folder or place it inside the project and move it to the computer.
If you have an suggestions, I would be more than happy to consider them!
Code snippets:
Deleting Temp Files:
Try
Dim peth As String = (DirectoryToInstall & "\Svatekl2.zip")
If File.Exists(peth) = True Then
FileSystem.Kill(peth)
End If
Catch
End Try
Try
If My.Computer.FileSystem.DirectoryExists(DirectoryToInstall & "\Svatekl3") = True Then
My.Computer.FileSystem.DeleteDirectory(DirectoryToInstall & "\Svatekl3", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin, FileIO.UICancelOption.ThrowException)
End If
Catch
End Try
Moving the zip file...
Private Sub MoveZip()
IO.File.WriteAllBytes(DirectoryToInstall & "\Svatekl2.zip", My.Resources.Svatekl2)
End Sub
Extracting...
Private Sub MyExtract()
Dim ZipToUnpack As String = (DirectoryToInstall & "\Svatekl2.zip")
Dim UnpackDirectoryToInstall As String = (DirectoryToInstall & "\Svatekl3")
Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
Dim e As ZipEntry
For Each e In zip1
e.Extract(UnpackDirectoryToInstall, ExtractExistingFileAction.OverwriteSilently)
Next
End Using
End Sub
To move the files I use a TON of code... I will not post it all here, I will just give you an example of how one of them looks! (They all look really similar)
If SafeShot.Checked = True Then
My.Computer.FileSystem.MoveDirectory(DirectoryToInstall & "\Svatekl3\Svatekl2\SafeShot\Allies and Dead\scripts", (DirectoryToInstall) & "\res_mods\0.9.7\scripts", True)
End If
Lastly it runs the DeleteTemp() again which is the first thing it does in the installation process as well.