@@ -45,7 +45,7 @@ public static void UpdateIfOld()
45
45
}
46
46
catch ( Exception exception )
47
47
{
48
- Log . LogError ( "Auto update failed, error: '{Exception }'" , exception ) ;
48
+ Log . LogError ( exception , "Auto update failed, error: '{ErrorMessage }'" , exception . Message ) ;
49
49
ConsoleWriter . WriteWarning ( "Auto update failed. Check logs for details" ) ;
50
50
}
51
51
}
@@ -81,13 +81,14 @@ protected override int Execute()
81
81
}
82
82
catch ( Exception exception )
83
83
{
84
- Log . LogError ( "Fail to install cement" , exception ) ;
84
+ Log . LogError ( exception , "Fail to install cement: '{ErrorMessage}' " , exception . Message ) ;
85
85
ConsoleWriter . WriteError ( "Fail to install cement: " + exception ) ;
86
86
}
87
87
88
88
var server = CementSettings . Get ( ) . CementServer ;
89
89
Log . LogInformation ( $ "Cement server: { server } ") ;
90
- var updater = server == null
90
+
91
+ var updater = server == null
91
92
? ( ICementUpdater ) new CementFromGitHubUpdater ( Log )
92
93
: ( ICementUpdater ) new CementFromServerUpdater ( server , branch , Log ) ;
93
94
@@ -99,23 +100,39 @@ private static void CreateRunners()
99
100
const string cmdText = @"@echo off
100
101
""%~dp0\dotnet\cm.exe"" %*
101
102
SET exit_code=%errorlevel%
102
- if exist %~dp0\dotnet\cm_new.exe (
103
- copy %~dp0\dotnet\cm_new.exe %~dp0\dotnet\cm.exe /Y > nul
104
- del %~dp0\dotnet\cm_new.exe > nul
105
- )
103
+ if exist %~dp0\dotnet\win10-x64\cm.exe (
104
+ copy %~dp0\dotnet\win10-x64\cm.exe %~dp0\dotnet\cm.exe /Y > nul
105
+ del %~dp0\dotnet\win10-x64\cm.exe > nul
106
+ ) else (
107
+ if exist %~dp0\dotnet\cm_new.exe (
108
+ copy %~dp0\dotnet\cm_new.exe %~dp0\dotnet\cm.exe /Y > nul
109
+ del %~dp0\dotnet\cm_new.exe > nul
110
+ )
111
+ )
106
112
cmd /C exit %exit_code% > nul" ;
107
113
108
114
var bashTextUnix = @"#!/bin/bash
109
115
path=""`dirname \""$0\""`/dotnet/cm.exe""
110
- cmd=""mono $path""
116
+ usingMono=""mono ""
117
+ if [ -f ~/bin/dotnet/linux-x64/cm ]
118
+ then
119
+ usingMono=""""
120
+ fi
121
+ cmd=""$usingMono$path""
111
122
for word in ""$@""; do cmd=""$cmd \""$word\""""; done
112
123
eval $cmd
113
124
exit_code=$?
114
- if [ -f ~/bin/dotnet/cm_new.exe ];
125
+ if [ -f ~/bin/dotnet/linux-x64/cm ];
115
126
then
116
- cp ~/bin/dotnet/cm_new.exe ~/bin/dotnet/cm.exe
117
- rm ~/bin/dotnet/cm_new.exe
127
+ cp ~/bin/dotnet/linux-x64/cm ~/bin/dotnet/cm.exe
128
+ rm ~/bin/dotnet/linux-x64/cm
118
129
chmod u+x ~/bin/dotnet/cm.exe
130
+ else
131
+ if [ -f ~/bin/dotnet/cm_new.exe ]
132
+ then
133
+ cp ~/bin/dotnet/cm_new.exe ~/bin/dotnet/cm.exe
134
+ rm ~/bin/dotnet/cm_new.exe
135
+ fi
119
136
fi
120
137
exit $exit_code" ;
121
138
bashTextUnix = bashTextUnix . Replace ( "\r \n " , "\n " ) ;
@@ -125,11 +142,17 @@ chmod u+x ~/bin/dotnet/cm.exe
125
142
args=$@
126
143
$path ""$@""
127
144
exit_code=$?
128
- if [ -f ~/bin/dotnet/cm_new.exe ];
145
+ if [ -f ~/bin/dotnet/os-x64/cm ];
129
146
then
130
- cp ~/bin/dotnet/cm_new.exe ~/bin/dotnet/cm.exe
131
- rm ~/bin/dotnet/cm_new.exe
147
+ cp ~/bin/dotnet/os-x64/cm ~/bin/dotnet/cm.exe
148
+ rm ~/bin/dotnet/os-x64/cm
132
149
chmod u+x ~/bin/dotnet/cm.exe
150
+ else
151
+ if [ -f ~/bin/dotnet/cm_new.exe ]
152
+ then
153
+ cp ~/bin/dotnet/cm_new.exe ~/bin/dotnet/cm.exe
154
+ rm ~/bin/dotnet/cm_new.exe
155
+ fi
133
156
fi
134
157
exit $exit_code" ;
135
158
@@ -196,7 +219,7 @@ private bool UpdateBinaries(ICementUpdater updater, string oldHash, string newHa
196
219
}
197
220
catch ( WebException webException )
198
221
{
199
- Log . LogError ( "Fail self-update, exception: '{Exception }'" , webException ) ;
222
+ Log . LogError ( webException , "Fail self-update, exception: '{ErrorMessage }'" , webException . Message ) ;
200
223
201
224
if ( webException . Status == WebExceptionStatus . ProtocolError && webException . Response != null )
202
225
{
@@ -239,9 +262,7 @@ private void CopyNewCmExe(string from)
239
262
Log . LogDebug ( "dotnet install folder: " + dotnetInstallFolder ) ;
240
263
241
264
var cm = Path . Combine ( from , "cm.exe" ) ;
242
- var cmNew = Path . Combine ( from , "cm_new.exe" ) ;
243
- File . Copy ( cm , cmNew , true ) ;
244
- if ( ! IsInstallingCement && File . Exists ( Path . Combine ( dotnetInstallFolder , "cm.exe" ) ) )
265
+ if ( ! IsInstallingCement && File . Exists ( Path . Combine ( dotnetInstallFolder , "cm.exe" ) ) )
245
266
File . Delete ( cm ) ;
246
267
247
268
var files = Directory . GetFiles ( from , "*" , SearchOption . AllDirectories ) ;
0 commit comments