1

When playing around creating new Visual Studio projects to try out various technologies, or a weekend project, I want an easy way to zip up my source and not worry about .pdb, obj/bin files, etc.

So many years ago, I came up with a set of .bat files, one of which is: zipall.bat that looks like this:

del all.zip
pkzip -add -excl=Backup\* -path -rec all

Before running it, I would run another batch file: clean.bat that looks like this:

del/f/s/q *.aps        2>nul
del/f/s/q *.bsc        2>nul
del/f/s/q *.exp        2>nul
del/f/s/q *.idb        2>nul
del/f/s/q *.ilk        2>nul
del/f/s/q *.lib        2>nul
del/f/s/q *.ncb        2>nul
del/f/s/q *.obj        2>nul
del/f/s/q *.opt        2>nul
del/f/s/q *.pch        2>nul
del/f/s/q *.pdb        2>nul
del/f/s/q *.plg        2>nul
del/f/s/q *.sbr        2>nul
del/f/s/q *.suo        2>nul
del/f/s/q *.sdf        2>nul

del/f/s/q /ah *.suo        2>nul

del/f/s/q BuildLog.htm    2>nul

for /f "delims=;" %%i in ('dir "TempPE" /s/b /ad')         do rmdir /s/q "%%i"
for /f "delims=;" %%i in ('dir "obj" /s/b /ad')            do rmdir /s/q "%%i"
for /f "delims=;" %%i in ('dir "_ReSharper*" /s/b /ad')    do rmdir /s/q "%%i"
for /f "delims=;" %%i in ('dir "TestResults*" /s/b /ad')   do rmdir /s/q "%%i"

Periodically, I would have to update the list with extensions that newer tools introduced.

Incidentally, the reason for the "excl=Backup*" option in pkzip is so that I maintain backups of the zip files. backup.bat looks like this:

mkdir Backup 2>nul
if not exist all.zip goto :eof
set datex=%date:/=-%
set timex=%time::=-%
set filename="Backup\%datex% %timex%.zip"
copy all.zip %filename%

Since Visual Studio 2013 has Git built-in, I don't bother with the backups anymore.

When creating a new Project in Visual Studio 2013, if you specify "Create new Git repository", it will create a hidden .gitignore file which is way more exhaustive than my clean.bat. Is there a way to use that list with pkzip so that when zipping, it ignores the files in .gitignore?

zumalifeguard
  • 8,648
  • 5
  • 43
  • 56
  • *(This is a self-answered question. Please see http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/ )* – Robert Harvey Jan 19 '15 at 19:22

1 Answers1

6

The .gitignore file is created when you create a Visual Studio project with the "Create new Git repository" selected.

You don't need to use pkzip because Git has the archiving feature built-in.

Just type: git archive -o all.zip HEAD

and it will create all.zip of the latest source, without any of the stuff you don’t want in the .zip file like bin, obj, exes, nuget assemblies, etc.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
zumalifeguard
  • 8,648
  • 5
  • 43
  • 56