@@ -16,21 +16,29 @@ class Program
1616
1717 static void Main ( string [ ] args )
1818 {
19- System . Threading . Thread . Sleep ( 20000 ) ;
20- UpdateData updateData = new UpdateData ( ) ;
21- updateData . SaveUpdateData ( "D:\\ UpdateData.json" ) ;
2219 temporaryFolder = GetTemporaryDirectory ( ) ;
20+ Console . WriteLine ( "AutoActions Updater" ) ;
21+ Console . WriteLine ( "" ) ;
22+ Console . WriteLine ( "" ) ;
23+ Console . WriteLine ( "Updating AutoActions..." ) ;
2324 try
2425 {
2526 bool download = bool . Parse ( args [ 0 ] ) ;
2627 string zip = GetZip ( download , args [ 1 ] ) ;
2728 string targetFolder = args [ 2 ] ;
2829 string callingProcess = args [ 3 ] ;
2930 Update ( zip , targetFolder , callingProcess ) ;
31+ Console . WriteLine ( $ "Starting { callingProcess } ...") ;
32+ System . Threading . Thread . Sleep ( 2000 ) ;
3033 Process . Start ( Path . Combine ( targetFolder , $ "{ callingProcess } .exe") ) ;
3134
3235 }
33-
36+ catch ( Exception ex )
37+ {
38+ Console . WriteLine ( ex . ToString ( ) ) ;
39+ Console . WriteLine ( "Press any key to close this window." ) ;
40+ Console . ReadKey ( ) ;
41+ }
3442
3543 finally
3644 {
@@ -44,12 +52,14 @@ private static string GetZip(bool download, string path)
4452 string updateZip = Path . Combine ( temporaryFolder , "Update.zip" ) ;
4553 if ( download )
4654 {
47- updateZip = Path . Combine ( temporaryFolder , "Update.zip ") ;
55+ Console . WriteLine ( $ "Downloading from { path } ... ") ;
4856 using ( WebClient myWebClient = new WebClient ( ) )
4957 {
5058 // Download the Web resource and save it into the current filesystem folder.
5159 myWebClient . DownloadFile ( path , updateZip ) ;
5260 }
61+ Console . WriteLine ( $ "Finished download.") ;
62+
5363 }
5464 else
5565 File . Copy ( path , updateZip , true ) ;
@@ -58,8 +68,9 @@ private static string GetZip(bool download, string path)
5868
5969 private static void Update ( string zip , string targetFolder , string callingProcess )
6070 {
61- System . Threading . Thread . Sleep ( 2000 ) ;
71+ System . Threading . Thread . Sleep ( 1000 ) ;
6272 ZipFile . ExtractToDirectory ( zip , temporaryFolder ) ;
73+ Console . WriteLine ( $ "Extrating zip to { temporaryFolder } ...") ;
6374 File . Delete ( zip ) ;
6475 UpdateData updateData = UpdateData . LoadFromFile ( Path . Combine ( temporaryFolder , "UpdateData.json" ) ) ;
6576 Process [ ] processes = Process . GetProcessesByName ( callingProcess ) ;
@@ -73,16 +84,24 @@ private static void Update(string zip, string targetFolder, string callingProces
7384 filesToCopy . Remove ( Path . Combine ( temporaryFolder , "AutoActions.Updater.exe" ) ) ;
7485 if ( filesToCopy . Contains ( Path . Combine ( temporaryFolder , "AutoActions.Updater.pdb" ) ) )
7586 filesToCopy . Remove ( Path . Combine ( temporaryFolder , "AutoActions.Updater.pdb" ) ) ;
87+ Console . WriteLine ( $ "Updating files...") ;
88+
7689 foreach ( string file in filesToCopy )
7790 {
91+
7892 string targetFileName = Path . Combine ( targetFolder , Path . GetFileName ( file ) ) ;
93+ Console . WriteLine ( $ "Updating { targetFileName } ") ;
7994 if ( File . Exists ( targetFileName ) )
8095 File . Delete ( targetFileName ) ;
8196 File . Move ( file , targetFileName ) ;
8297 }
98+ if ( updateData . FilesToDelete . Count > 0 )
99+ Console . WriteLine ( $ "Removing files files...") ;
100+
83101 foreach ( string file in updateData . FilesToDelete )
84102 {
85103 string targetFileName = Path . Combine ( targetFolder , Path . GetFileName ( file ) ) ;
104+ Console . WriteLine ( $ "Removing { targetFileName } ") ;
86105 if ( File . Exists ( targetFileName ) )
87106 File . Delete ( targetFileName ) ;
88107 }
0 commit comments