Skip to content

Instantly share code, notes, and snippets.

@ddieppa
Last active November 22, 2022 21:57
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ddieppa/8508c70608994ce70e13 to your computer and use it in GitHub Desktop.
Save ddieppa/8508c70608994ce70e13 to your computer and use it in GitHub Desktop.
How to zip dotnet projects
published: true

How to zip dotnet projects

Visual Studio project folders contains a lot of files that it generates each time you compile your project, so you don't need them when zipping the folder, what about if we could use .gitignore?

There are ways to do this :) lets check them down

Using 7Zip

Here is the link to 7zip if not installed

Steps:

  • Open a command prompt

  • Copy this into the console:

    7z.exe a -t7z "C:\Destination\Path\%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2% BackupName.7z" "C:\Source\Path\FolderToBeBackup" -bd  -mx9 -xr@"C:\Path\To\ExcludeListName"
  • Press Enter

The exclude list could be a copy of a .gitignore file

Git archive functionality

If the projects are git repos, the git archive cli command can be used

Unix

git archive HEAD -o ${PWD##*/}.zip

PowerShell

git archive HEAD -o ../$(Split-Path -Path ${PWD} -Leaf)-$(Get-Date -UFormat "%Y.%m.%d-%H.%M").zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment