17

Anyone know of good articles for setting up a new project with git and ASP.NET MVC?

Just wondering what to include and ignore and what to do about deployment.

Gerwald
  • 1,549
  • 2
  • 18
  • 42
user77339
  • 335
  • 3
  • 7

5 Answers5

36

Gitignore

You asked about what to ignore -- here is my default .gitignore for ASP.NET MVC projects:

###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache
*.suo
# Include dlls if they’re in the NuGet packages directory
!/packages/*/lib/*.dll
!/packages/*/lib/*/*.dll
# Include dlls if they're in the CommonReferences directory
!*CommonReferences/*.dll
####################
# VS Upgrade stuff #
####################
UpgradeLog.XML
_UpgradeReport_Files/
###############
# Directories #
###############
bin/
obj/
TestResults/
###################
# Web publish log #
###################
*.Publish.xml
#############
# Resharper #
#############
/_ReSharper.*
*.ReSharper.*
############
# Packages #
############
# it’s better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
######################
# Logs and databases #
######################
*.log
*.sqlite
# OS generated files #
######################
.DS_Store?
ehthumbs.db
Icon?
Thumbs.db

Setting up a new project

For help on setting up a new project, I would install msysgit since you're most likely on Windows and check out learn.github to learn about getting started with git. Of course, the master (Skeet) suggests you do most everything from the console -- and I tend to agree with him. Git is just easier that way IMHO. If you'd like a handy git reference, check out the git reference.

Deployments

As somebody else already mentioned -- check out AppHarbor for deployments. Those guys aim to be the 'Heroku of ASP.NET'.

Community
  • 1
  • 1
Dan Esparza
  • 28,047
  • 29
  • 99
  • 127
  • 4
    +1 Thanks for this. Two suggestions: first, you can add `*.user` after `*.suo`, as these are user-specific files (https://github.com/github/gitignore/blob/master/Global/VisualStudio.gitignore). Second and **MOST IMPORTANTLY**, add `!/packages/*/lib/*/*.dll` after `!/packages/*/lib/*.dll`. Today I got bitten by this while trying to deploy to AppHarbor and had my build failing. After a while I finally figured some NuGet packages (like WebActivator and Ninject) use a folder structure under `lib` (i.e. `/packages/Ninject.2.2.1.4/lib/net40-Full/Ninject.dll`). Hope this helps others! – Daniel Liuzzi Sep 01 '11 at 03:07
  • Another suggestion for Windows git development: The new Windows Git client - http://windows.github.com/ It's geared for github, but you can use it with other local repositories (and even sync with hosted repos like bitbucket.org) – Dan Esparza Aug 04 '12 at 15:00
  • @DanielLiuzzi updated with your suggestion because I just got bit with this trying to use Entity Framework 5.x (which uses NuGet and stores in a subdirectory format like you described) – Dan Esparza Sep 15 '12 at 00:37
  • 3
    Dan, now that NuGet supports [package restore](http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages), DLLs in subdirs are really no longer a problem; you just ignore **the whole folder** (i.e. `packages/`), and NuGet will download missing packages for you on build. The repo size drops dramatically without all those DLLs in there (mine got 47 MB lighter!) – Daniel Liuzzi Sep 15 '12 at 16:21
  • 1
    If you're reading this and wondering "What the heck is package restore?" just check out this article: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages – Dan Esparza Sep 28 '12 at 14:14
4

There is a great post on codebetter.com today. It is about OSS projects but I bet it is applicable to you as well because it is describing GIT.

The right part of the article is the link to Kyle's blog and especially Getting Started with Git and GitHub on Windows.

David Pokluda
  • 10,693
  • 5
  • 28
  • 26
  • 1
    Cool thanks for the tip. Posted the correct link below. http://codebetter.com/blogs/aaron.jensen/archive/2009/03/12/hosting-your-oss-project-on-github.aspx – user77339 Mar 14 '09 at 04:15
3

If you're already using git and ASP MVC you should also check out AppHarbor http://appharbor.com/ for deployment and hosting. It integrates right into your workflow.

Dan
  • 6,008
  • 7
  • 40
  • 41
0

Mine is super simple:

*/packages/*
/packages/*
obj/
bin/
TestResults/
_ReSharper.*
*.csproj.user
*.resharper.user
*.resharper
*.suo
*.cache
*~
*.swp
*.resharper.user
*.rptproj.user
*.db
*.sdf
*.tmp

For the example of gitignore files check github gitignore examples and one for visual studio VisualStudio.gitignore

ITmeze
  • 1,902
  • 2
  • 21
  • 32