appharbor_github

Deploy your first ASP.Net MVC App to AppHarbor

If you’ve been developing ASP.Net MVC apps lately you might be thinking some online or cloud based app hosting platform available as PaaS for Microsoft technologies specially for hosting ASP.Net MVC apps just like OpenShift, Heroku and other platforms are available for technologies like Ruby, Python, PHP, Node.js and even supporting CMS like WordPress. The good news for ASP.Net developers is that there is a PaaS platform available which you might already know. The platform is AppHarbor. AppHarbor runs over Amazon AWS and has some nice features that I won’t go into the details of. If you are interested in knowing how AppHarbor works you can see their page here.

Regardless of AppHarbor provides a decent service, new developers might still face some difficulty in deploying their applications to AppHarbor. Specially, if you are developing apps based on new Visual Studio 2015 templates like MVC. Their are different ways to deploy but I would follow below approach which in my opinion is good and provide auto deployment or in other words Continuous Integration (CI).

What you need?

We will be using following tools and accounts.

  • Visual Studio 2015 (any edition, I used Professional version)
  • ASP.Net MVC app created from VS2015 MVC template
  • GitHub repo for the app/project
  • Local git repo for app with remote repo set as your GitHub app repo
  • AppHarbor app

What’s not covered?

Our focus today is deployment of our ASP.Net MVC app to AppHarbor. Therefore, we won’t be going into the details of how application is created or its architecture, what’s new in Visual Studio 2015, what is MVC, what is Git and GitHub, and how to connect your GitHub repo to AppHarbor etc. We will assume that you already have all the pre-requisites and we will just focus what problems can we come across during deployment and how to fix them.

Deployment Steps

  1. Initialize a Git repo and connect it with your GitHub repo.
  2. Create AppHarbor app from your GitHub repo. Whenever we commit/push our changes to our GitHub repo AppHarbor will automatically fetches the latest push and build it. Upon successful build it will deploy the app on its server otherwise it will keep last successful build. This makes things very easy.
  3. Create an ASP.Net MVC application using Visual Studio 2015 MVC template.
  4. Add the packages folder to .gitignore
  5. Enable NuGet Package Restore. In VS2015 click Tools>Options and then select NuGet Package Manager and make sure both checkboxes are checked in this section.
  6. In VS2015 right click on project and click properties, then goto Build Events tab. In the Post-build event command line text area paste the following command.
    1. if not exist “$(WebProjectOutputDir)\bin\Roslyn” md “$(WebProjectOutputDir)\bin\Roslyn”
      start /MIN xcopy /s /y /R “$(OutDir)roslyn\*.*” “$(WebProjectOutputDir)\bin\Roslyn”
  7. Now commit and push your changes to GitHub.
  8. That’s it! AppHarbor will automatically fetch the latest version changes and build it and you can check your AppHarbor application on its URL.

What’s Next?

There are few things that you need to take care of specially related to security. This MVC app uses SQL Server Compact which isn’t a good option for production level apps. Secondly, your connection string or password to database must not be committed to public GitHub repo.

This post will just give you smooth start without any difficulties which I faced among other people that you can see in the resources section below.

If you think this was helpful or if I have missed anything please do let me know in the comments below.

Happy coding!

Resources

  1. https://blog.appharbor.com/2012/02/06/use-nuget-package-restore-to-avoid-pushing-packages-to-appharbor
  2. https://support.appharbor.com/discussions/problems/79727-error-msb3202-when-building
  3. https://support.appharbor.com/discussions/problems/78633-cant-build-aspnet-mvc-project-generated-from-vstudio-2015-enterprise#comment_37577678
Entrepreneur-picture1

1 reason why you shouldn’t be an Entrepreneur?

There has been a lot of buzz about entrepreneurship in recent years and lot of people have come up as great entrepreneurs and have set a trend for others to pursue in this direction. This term was not very common in the past and due to which lot of people don’t really know what entrepreneurship really means. Lot of people also mix it with just doing business. That is true somewhat but that means every businessman is an entrepreneur? That is not the case. Lot of people think doing technology enabled business is entrepreneurship. This is also not very true although in our modern era technology has played a big role in business and life.

So, if you try to dig it more, talk to entrepreneurs and other people you will start differentiating business and entrepreneurship. There are different traits of entrepreneurship. Entrepreneur actually take risk and starts a new business on the opportunity he/she finds.

Let me explain. First let’s describe what is opportunity. People come across different problems in life. Opportunity is basically a solution to that problem. You might be thinking how come a problem be an opportunity. You are right and this is where things start to go wrong.

Business is to earn money to fulfill their family needs. While entrepreneurship is finding people’s problems and make money from that problem.

If you hold for a moment and think what entrepreneurs do is ask money from people just to solve their problem. In my opinion this is not a right approach and creates a culture where people instead of helping each other will ask for money to give them a hand or solve their problem. This kills the humanity and one will always thought of making money from others problems.

I won’t say doing business is wrong, but the approach of entrepreneurship is. And this is the one reason you shouldn’t be an entrepreneur if you really cares about people and want to help them.

At the end of the day this is my thought and doesn’t represent anyone. Let me know in comments below if you agree with me or what are your thoughts on doing business and entrepreneurship.