Sitecore Habitat Home installation – Build Error & PackageReference

Currently, i am starting a new project which is based on eCommerce solution build in legacy .net platform which i need to move to Sitecore. I wanted to have a look at all the solutions & structures available in community like Habitat, Sitecore Commerce 9.0.2 (A storefront example with the help of SXA), Habitat Home Demo.

I have already configured Habitat solution many times in local or on server without visual studio installed. I also installed Sitecore Commerce 9.0.2 with the help of installation guide provided by Sitecore and an excellent blog by @viet_hoang_sc: https://buoctrenmay.com/2018/03/09/step-by-step-guide-for-sitecore-commerce-9-installation-on-your-machine/ . Now, it was turn for Habitat Home Demo.

Habitat Home Demo

India witnessed first ever SUGCON in this region in May 2018. Where on second day, Implementing XC9 Habitat home Demo was on schedule. I got to see that demo and decided to install that at some time. Now, comes the real confusion. While searching on search engine, it always shows the Habitat (Helix) instead of Habitat Home Demo. There were couple of post from @viet_hoang_sc on this topic. Why couple of? because HabitatHome Demo is divided into two parts mainly:

Build Error & PackageReference

By following the guide and the blog mentioned above, i was able to set up all prerequisites. I was just far to run the gulp command either from command line or from Visual Studio Task Explorer. I executed default gulp task, it failed after nuget restore while building the solution. Error is:
2018-08-14 17_07_32-Window

I went to Visual studio and performed rebuild solution and to the surprise, it succeeded without any errors.
2018-08-15 14_12_54-HabitatHome - Microsoft Visual Studio (Administrator)
Then i expanded the Accounts project under Foundation layer to have a look there.

With surprise, i couldn’t find the packages.config. And not the packages folder even in repository. This may be new to you as well if you have not paid much attention to the Asp.Net Core & new csproj style in VS 2017.

For Asp.Net core 1.0 projects, project.json was responsible to store all these dependency related information. With introduction of VS2017, project.json is retired and information related to dependency and nuget packages included in csproj itself. This new pattern is called PackageReference https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files.

I have installed latest nuget from https://www.nuget.org/downloads and there wasn’t any issue restoring packages even with this new PackageReference format. So, it looked like issue was with new PackageReference format and Project references. With some research i come to know that there were some issues with old legacy CSProj + PackageReference until MSBuild 15.1.
2018-08-14 17_13_57-Window

Few links if you wanted to know more about the build issue overall:

To know more about project.json file: https://docs.microsoft.com/en-us/nuget/archive/project-json

To know more about PackageReference pattern: https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files

A guidance of converting package.json format to Packageeference using csproj properties: https://docs.microsoft.com/en-us/dotnet/core/tools/project-json-to-csproj. https://natemcmaster.com/blog/2017/03/09/vs2015-to-vs2017-upgrade.

There is a nice VS extension available to convert legacy packages.config style csproj into PackagReference pattern: https://marketplace.visualstudio.com/items?itemName=CloudNimble.NuGetPackageReferenceUpgrader

Solution

I was using VS 2017 with initial version of build tools. Installing latest stable version (15.7 or 15.8) of Visual Studio or just Build Tools for Visual Studio 2017 will solve the issue. And after this when you run the gulp command from command prompt, it will restore nuget packages, resolve dependencies correctly and build the projects successfully.

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s