Skip to content

Instantly share code, notes, and snippets.

@dominik-ba
Created November 9, 2018 13:57
Show Gist options
  • Save dominik-ba/06a7f1021eeb99d98929c3f0c378eacf to your computer and use it in GitHub Desktop.
Save dominik-ba/06a7f1021eeb99d98929c3f0c378eacf to your computer and use it in GitHub Desktop.
makes zip of special content for packages
@echo off
echo Building Package...
set arg1=%1
set mydir="%~p0"
cd %mydir%
::find package name
::convert \ to ;
SET convertdir=%mydir:\=;%
for /F "tokens=* delims=;" %%i IN (%convertdir%) DO call :LAST_FOLDER %%i goto :continue
:LAST_FOLDER
if "%1"=="" (
goto :EOF
)
set CURRENTDIRNAME=%1
SHIFT
goto :LAST_FOLDER
:continue
:: End Find Package Name
SET PACKAGENAME=%CURRENTDIRNAME%
SET ZIPFILE=%CURRENTDIRNAME%.zip
SET TEMPORARYFOLDER=%~dp0temp\\
::clean up
for /r %%i in (*.pyc) do (
echo deleting %%i now
del %%i
)
echo Create temporary Copy for final manipulation...
robocopy "%~dp0\" "%TEMPORARYFOLDER%" /nfl /ndl /njh /njs /ns /nc /np /s /XD "%TEMPORARYFOLDER%" >NUL
if /i "%arg1%" == "development" (
echo Perform Development Adjustments
cd %~dp0temp
for /r %%i in (discoveryPatterns\*.xml) do (
echo Adjust %%i for Development Environment
powershell -executionpolicy remotesigned -File ../../changeToDev.ps1 %%i
)
cd ..
)
echo Packaging to %ZIPFILE%...
cd %~dp0temp
:: Zip Directories
for /D %%i in (*) do (zip -qr %ZIPFILE% "%%i")
:: Zip descriptor.xml
zip -qr %ZIPFILE% descriptor.xml
:: Move one level up
move %ZIPFILE% ..\%ZIPFILE% >NUL
cd ..
:: Cleanup temporary folder
echo Cleanup...
rmdir %mydir%\temp /q /s
echo.
echo Finished packaging
echo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment