@REM XapShrink - Recompresses XAP files smaller - Based on XapReZip, but using KZIP to do the dirty work @REM Invoke as a VS post-build event like so: @REM C:\XapShrink\XapShrink.cmd $(TargetName).xap @echo off setlocal REM Define paths to zip.exe and unzip.exe set ZIPEXE="%~p0kzip.exe" set UNZIPEXE="%~p0unzip.exe" REM Define paths for intermediate files set XAP=%1 set XAPDIR=%~p1 set XAPBAK=%1.bak set XAPZIP=%1.zip set TMPDIR=%XAPDIR%tmp\ REM Output a banner message echo XapShrink: %XAP% REM Change to XAP file directory pushd %XAPDIR% REM Create the temporary work folder md tmp REM Unzip the current XAP file %UNZIPEXE% -o %XAP% -d %TMPDIR% REM Change to temp file directory cd %TMPDIR% REM Create the new XAP using KZIP %ZIPEXE% /y %XAPZIP% %TMPDIR%* REM Abort if something went wrong if ERRORLEVEL 1 goto :DONE REM Replace original XAP file with smaller one move /y %XAPZIP% %XAP% del /Q *.* cd.. rd tmp REM Output a success message echo XapShrink: Success :DONE REM Restore previous directory popd endlocal