summaryrefslogtreecommitdiff
path: root/src/zap/zapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zap/zapper.cpp')
-rw-r--r--src/zap/zapper.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/zap/zapper.cpp b/src/zap/zapper.cpp
index 683805eacf..5cecda827e 100644
--- a/src/zap/zapper.cpp
+++ b/src/zap/zapper.cpp
@@ -1457,6 +1457,7 @@ void Zapper::CompileAssembly(CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig)
DefineOutputAssembly(strAssemblyName, &hashAlgId);
SString strNativeImagePath;
+ SString strNativeImageTempPath;
HANDLE hFile = INVALID_HANDLE_VALUE;
StackSArray<HANDLE> hFiles;
@@ -1505,7 +1506,10 @@ void Zapper::CompileAssembly(CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig)
pAssemblyModule->SetPdbFileName(SString(strAssemblyName, SL(W(".ni.pdb"))));
- hFile = pAssemblyModule->SaveImage(strNativeImagePath.GetUnicode(), pNativeImageSig);
+ strNativeImageTempPath = strNativeImagePath;
+ strNativeImageTempPath.Append(W(".tmp"));
+
+ hFile = pAssemblyModule->SaveImage(strNativeImageTempPath.GetUnicode(), strNativeImagePath.GetUnicode(), pNativeImageSig);
}
// Throw away the assembly if we have hit fatal error during compilation
@@ -1520,6 +1524,11 @@ void Zapper::CompileAssembly(CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig)
CloseHandle(*i);
}
+ if (!WszMoveFileEx(strNativeImageTempPath.GetUnicode(), strNativeImagePath.GetUnicode(), MOVEFILE_REPLACE_EXISTING))
+ {
+ ThrowLastError();
+ }
+
if (!m_pOpt->m_silent)
{
GetSvcLogger()->Printf(W("Native image %s generated successfully.\n"), strNativeImagePath.GetUnicode());