Deploying an MVC4 C # application for Azure through GitHub. What should be in my .gitignore?

I have an ASP.NET, MVC4, C # application that I developed in Visual Studio 2012. So far, I have successfully deployed to the Azure website using the VS publishing tool.

Now, I have successfully set up Git publishing on the Azure website and linked it to the GitHub repository. I initialized the repository on my local computer and moved the entire batch to the GitHub repository. Lazur immediately pulled it all out, as it should.

Now, I expected that in the absence of a .gitignore file, this would not work perfectly, and I was right.

So my question is: Which of my local Visual Studio working directory should I omit from the repository? That is, what should be in my .gitignore?

Also, are there other factors that I should think about when trying to get the application to run on the Azure Website?

Notes:
1. I looked good at https://gist.github.com/2589150 , but it does not seem to match what I see in the VS working directory. <br> 2. https://github.com/github/gitignore/blob/master/CSharp.gitignore seems closer, and I'm currently working on this, trying to figure out which parts of it apply to my situation. For example, if I exclude bin / *, then the application will not be deployed to Azure.

UPDATE:
1) I disabled user errors by modifying the web.config file suggested by @levelnis:

<configuration> <system.web> <customErrors mode="Off"/> </system.web> </configuration> 

I found that my problem was with the database connection string, which was no longer converted to Azure using the VS publishing tool. I had to change this directly and commit the repo.

Top tip:. I found the right line by simply seeing that VS Publish was exposed on Azure by publishing a temporary Azure site with a different publishing profile.

This fixed the problem and the deployment went very smoothly.

2) At this point, my .gitignore file had the following:

  # Build Folders
     obj /

     # User-specific files
     * .user

     # SQL Server files  
     App_Data / *. Mdf
     App_Data / *. Ldf

It seems like I may have cut out a lot more for convenience, but that did not affect the proper deployment work through GitHub, which now works very smoothly.

Finally, a handy Git command to delete files from a repo without deleting them. A few examples:

  git rm -r --cached obj / *
     git rm -r --cached * / *. user

And then obviously add them to .gitignore before adding, committing and clicking.

+6
source share
2 answers

Your problem cannot be related to the absence of a .gitignore file. In the worst case scenario, you will include your compiled dlls in the bin folders in your repository - a really bad idea in terms of general maintenance, but not in terms of publishing to Azure.

Is the error a yellow screen of death or just a blank screen with this message? If this is the latter, it sounds as if the deployment failed. You can use FTP on the website and check where the website files are located. It also has a log directory that you will find there - it might have something to help diagnose the error. Here's the .gitignore from my project (you may need to add more files / delete some bits, but at least this will cause the DLL to crash):

 # git ignore file _ReSharper.* [B|b]in/ obj/ *.suo *.user 

It is not Azure specific, it is specific to ASP.NET. By the way, if you need to remove the DLLs and they were fixed, you need to add the bin path to .gitignore and delete all the DLLs, as well

EDIT: add <customErrors mode="Off"/> - at least it will tell you what the error is

+2
source

A good example of a gitignore file for Visual Studio is as follows:

https://gist.github.com/2589150

As far as publishing on Azure is concerned, I don’t know enough about this, but I think you will find here everything you need:

http://msdn.microsoft.com/en-us/library/windowsazure/hh420322.aspx

And even better, Microsoft's tutorial on publishing from Git to Azure:

http://www.windowsazure.com/en-us/develop/net/common-tasks/publishing-with-git/

0
source

All Articles