Setting up Habitat without having Visual Studio installed on server

Have you started checking Habitat architecture? If no, this is the best time to get started as Sitecore is evolving faster than it used to and customers are also asking competitive and best enterprise solutions. In this case sometime it becomes difficult to manage your project architecture specially in a big project/team. So, why not look at Habitat? an example provided by Sitecore as a best practice for Sitecore projects based on Helix architecture.

There are many resources available on how to setup Habitat for sitecore correctly like
https://github.com/Sitecore/Habitat (source code)
https://github.com/Sitecore/Habitat/wiki/01-Getting-Started (Geting started guide)
https://www.youtube.com/watch?v=FNqKZN9DH5I (step by step video tutorial on how to setup Habitat for Sitecore)

I ran into a situation where i needed to setup a Habitat on a plain server where i won’t find IIS, Visual Studio etc. installed.

So, lets get on a tour on setting up Habitat without VS installed, Issues which we might face and solutions.

  1. Install plain Sitecore: first step first. Install a plain Sitecore 8.2 Update 1 on which we will setup Habitat. We will use this later
  2. Clone/Download Habitat project: Clone the Habitat repository or download zip from https://github.com/Sitecore/Habitat.
  3. Node.Js: Install latest Node.Js from https://nodejs.org/en/
  4. Perform all the steps specified in https://github.com/Sitecore/Habitat/wiki/01-Getting-Started until step 5. Or you can follow the video tutorial https://www.youtube.com/watch?v=FNqKZN9DH5I
  5. Now, we have arrived at the step to build and publish the solution to the Habitat Sitecore website we installed in the beginning.
  6. Without having Visual Studio installed, we cannot use Task Runner Explorer of VS. So, we have to use command window to run gulp command.

Now, you will start encountering the issues when trying to run gulp commands using command prompt. Some of issues and solutions are mentioned below:

  1. Go to the project directory where you have cloned the habitat project or downloaded and unzipped a project.
  2. Run npm gulp command in that directory on to command window.
  3. Now, if you have not installed all the required modules properly from npm and try to execute gulp task like gulp default, then it will start giving error. In my case it was cannot find module gulp-msbuild. so rather running npm gulp command in project directory, run npm install command so that it will install all the required plugins along with gulp.
  4. I tried to run the default task specified in gulpfile.js using gulp default command. And i got the error saying gulp is not recognized as internal or external command. You required gulp-cli package to be installed to run gulp command from command window. So, if it is missing and you are facing this issue than run npm install -g gulp-cli command. Now once you have installed this package you can run the gulp command as gulp default from the command window.
  5. Running gulp default command again, You may face error saying Nuget package installation failed. As VS is not installed, Nuget will not be installed by default.So, you have to install Nuget command line from https://dist.nuget.org/win-x86-commandline/latest/nuget.exe or https://docs.nuget.org/consume/command-line-reference/.
  6. Running gulp default command again, Nuget package installation will get complete but you may face error saying Build Failed. As VS is not installed on server. So, you will required to install MSBuild tool. You can find it here: https://www.microsoft.com/en-in/download/details.aspx?id=48159
  7. Running gulp default command again, i got error saying MSBuild – microsoft.webapplication.targets was not found issue even though we have installed MSBuild tool on the server. To resolve this, i just copied C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications folder from local to the server and tried run command again.
  8. Encountered error stdout maxbuffer exceeded, error in build gulp task.
    So, i come to know that there must be something tricky with MSBuild. It is missing something that generally shifts with VS in our local machine. I found a solution as per: http://nickberardi.com/a-net-build-server-without-visual-studio. We need to perform third step from the link, which says copy both the below folders from your local machine to server:

    • C:\Program Files (x86)\MSBuild
    • C:\Program Files (x86)\Reference Assemblies

    Between those two directories MSBuild and Reference Assemblies you have most everything you need to complete any build that Visual Studio can do by it self. And the above steps while simple, but not obvious, provide a nice clean build server that doesn’t require Visual Studio to operate.

Keep reading Helixian.