Archiving your code



Title of this blog post may sound very weird in 2018 while github / vsts / bitbucket are still up and running. However, it still seems to be very common to archive your solution and upload it to cloud or send it by email. Don’t ask me why, it is just still there.

The most painful and annoying mistake you can make is to include dependencies that can be easily downloaded or compiled code. Painful because it may significantly increase the size of the archive and annoying because you may have to download it for hours because of it.

The problem in numbers

Blank .NET Standard 2.0 Xamarin.Forms application targeting Android and iOS with latest and greatest NuGet packages is about ±280MB and ±100MB zipped. However, after removing the \packages, \bin & \obj directories, solution size decreases to ±380KB and ±50KB zipped. That’s a huge difference!



The easiest way to archive a solution the right way is by using the next command:

zip -r ../ . -x packages/\* */bin/\* */obj/\* *.git/\* *.vs/\*

Please note that this is a simple MacOS command to create a zip archive with recurse into directories (-r) which will generate a based on current directory (.) excluding (-x) the next directories packages, bin, obj, .git and .vs.


The alternative and preferred way to create an archive would be using git that will respect the .gitignore file. If you are new to git.gitignore is a list that describes files and folders that should not be a part of your repository, more information can be found here and there is an example given here.

Let’s take a look on the git command:

git archive –format zip –output my_lovely_branch

git is much cleaner compare to pure zip command. There is no need to specify the exclude filter manually since .gitignore is in use. You can specify a commit or branch to be archived and etc. More information can be found here.

Keep in mind that you need to have at least one commit in order to use this solution.


Your solution repo / archive should contain only the essential bits and bytes. If it contains inessentials, it doesn’t look professional and you better get familiar with best practises.

P.S.: I created an open source add-in for VS for Mac that include the solutions above. You can find it here.

11 thoughts on “Archiving your code

      1. It doesn’t work on a mac, but the core part of the project can easily be converted to .net core, so it will work on a mac. You cannot run the UI part on a mac (maybe with mono and a few changes)


  1. I’d say there’s a case to be made for including dependencies, although that is dependent on what your archive is for; whether it’s to send to someone or keep for a later date.

    There’s no guarantee that the dependencies will still be available when you come to load your archive a few years down the line!


      1. Yeah, after the debacle with left-pad (which I believe was npm) I’m inclined to believe that’s the case too, and we go out of our way to ensure that dependencies aren’t in repositories (including creating unofficial packages for libraries that don’t yet have them) but it’s worth remembering sometimes that nothing is forever on the Internet!


  2. Hi!
    Could you tell how you’ve done that? How you published your add-in? I don’t understand how edit sources GitHub URL when project has been created.


    1. Hello Max,

      Currently Microsoft is working on a new process for publishing to the VS for Mac extension gallery, and in the meantime they manually approve authors and projects on Regarding your second question: “I don’t understand how edit sources GitHub URL when project has been created.” – could you please be more specific?


Leave a Reply to MatthewSteeples Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s