Merge "Package VC runtime dlls with Python3"
diff --git a/kokoro/build.cmd b/kokoro/build.cmd
index 2383bee..280902a 100644
--- a/kokoro/build.cmd
+++ b/kokoro/build.cmd
@@ -2,8 +2,12 @@
 :: %1 = python_src
 :: %2 = dest_dir
 
+ECHO ON
+
 SET PYTHON_SRC=%1
-SET DEST=%2
+SET OUT=%2
+SET DEST=%3
+SET KOKORO_BUILD_ID=%4
 
 cd %PYTHON_SRC%
 md %DEST%
@@ -17,13 +21,27 @@
 CALL PCbuild\build.bat -c Release -p x64
 IF %ERRORLEVEL% NEQ 0 goto :end
 
+ECHO ON
+ECHO ## Installing python...
+CALL python.bat PC\layout --copy %OUT% --include-dev
+IF %ERRORLEVEL% NEQ 0 goto :end
+
+ECHO ON
+ECHO ## Installing ucrt...
+SET "UCRT_PATH=%WindowsSdkDir%\Redist\%WindowsSDKVersion%\ucrt\DLLs\x64"
+IF NOT EXIST "%UCRT_PATH%" (
+    SET "UCRT_PATH=%WindowsSdkDir%\Redist\ucrt\DLLs\x64"
+)
+COPY "%UCRT_PATH%\*" "%OUT%"
+IF %ERRORLEVEL% NEQ 0 goto :end
+
 ECHO ## Packaging python...
-CALL PCBuild\amd64\python.exe PC\layout --zip %DEST%\python3-windows-%KOKORO_BUILD_ID%.zip --include-dev
+powershell Compress-Archive -Path "%OUT%\*" -DestinationPath "%DEST%\python3-windows-%KOKORO_BUILD_ID%.zip"
 IF %ERRORLEVEL% NEQ 0 goto :end
 
 :: Packages all downloaded externals in externals
 ECHO ## Packaging externals...
-powershell Compress-Archive -Path .\externals -DestinationPath %DEST%\python3-externals-%KOKORO_BUILD_ID%.zip
+powershell Compress-Archive -Path ".\externals\*" -DestinationPath "%DEST%\python3-externals-%KOKORO_BUILD_ID%.zip"
 IF %ERRORLEVEL% NEQ 0 goto :end
 
 :end
diff --git a/kokoro/kokoro_build.cmd b/kokoro/kokoro_build.cmd
index f01e5ac..d2a6eea 100644
--- a/kokoro/kokoro_build.cmd
+++ b/kokoro/kokoro_build.cmd
@@ -2,9 +2,15 @@
 :: The final directory name in this path is determined by the scm name specified
 :: in the job configuration
 
+SET OUT=%KOKORO_ARTIFACTS_DIR%\out
 SET DEST=%KOKORO_ARTIFACTS_DIR%\dest
 SET PYTHON_SRC=%KOKORO_ARTIFACTS_DIR%\git\cpython3
 
-call %~dp0\build.cmd "%PYTHON_SRC%" "%DEST%"
+:: Initialize environment variables.
+CALL "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" amd64
+IF %ERRORLEVEL% NEQ 0 goto :end
 
+CALL "%~dp0\build.cmd" "%PYTHON_SRC%" "%OUT%" "%DEST%" "%KOKORO_BUILD_ID%"
+
+:end
 exit /b %ERRORLEVEL%