I have an ASP.NET, MVC4, C# application which I have developed in Visual Studio 2012. Up to now I have deployed successfully to an Azure website using the VS Publish facility.
I have now successfully set up Git publishing on the Azure Website and linked it with a GitHub repository. I have initialized a repository on my local machine and pushed the whole lot to the GitHub repo. Azure immediately pulled all this as it should.
Now, I was expecting that in the absence of a .gitignore file this wouldn't work perfectly and I was right.
So my question is: What, from my local Visual Studio working directory should I be omitting from the repository? I.e. what should be in my .gitignore?
Also, are there any other factors I should be thinking about in trying to get the application working on the Azure Website?
Notes:
1. I had a good look at https://gist.github.com/2589150 but it doesn't seem to tally with what I am seeing in the VS working directory.
2. https://github.com/github/gitignore/blob/master/CSharp.gitignore seems nearer and I am currently working through this trying to understand which bits of it apply to my situation. For example, if I exclude bin/* then the application fails to deploy on Azure.
UPDATE:
1) I switched off custom errors by modifying my web.config file as suggested by @levelnis:
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
I found my problem was the database connection string which was no longer being converted to Azure by the VS Publish facility. I had to modify this directly and commit to the repo.
Top tip: I found the correct string by simply looking at what the VS Publish facility put up on Azure by publishing to a temporary Azure website with a different publish profile.
This fixed the problem and the deployment went very smoothly.
2) By this time I had the following as my .gitignore file:
# Build Folders obj/ # User-specific files *.user # SQL Server files App_Data/*.mdf App_Data/*.ldf
It seems that I can probably cut out a lot more for tidiness sake, but this was not affecting the correct operation of deploying via GitHub which now actually works extremely smoothly.
Lastly, the handy git command for removing files from the repo without deleting them. A couple of examples:
git rm -r --cached obj/* git rm -r --cached */*.user
And then obviously add these to .gitignore before adding, committing and pushing.
Your issue may not be related to not having a .gitignore file. At worst, you'll be including your compiled dlls in the bin folders within your repository - a really bad idea from a general maintenance perspective but not from a publishing to Azure perspective.
Is the error a Yellow Screen Of Death or simply a blank screen with that message? If it's the latter it sounds as though the deployment failed. You can FTP in to the website and check whether the website files are where they should be. There's also a Logs directory that you'll find there - it may have something that'll help diagnose the error. Here's the .gitignore from my project (yours may need more stuff adding/some bits removing but at least it'll get the dlls out of the way):
# git ignore file
_ReSharper.*
[B|b]in/
obj/
*.suo
*.user
That isn't Azure specific, it's ASP.NET specific. Incidentally, if you need to remove the dlls and they've been committed, you'll need to add the bin path to .gitignore and delete all the dlls as well
EDIT: add <customErrors mode="Off"/>
- at least it'll tell you what the error is
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With