Skip to content

Setup development environment

Lukas Gerbenis edited this page Dec 9, 2015 · 15 revisions

Pre-requisites:

  • Remote or local SQL Server / SQL Server Express
  • .NET Framework >= 4.5
  • IIS with ASP.NET
  • Mvc >= 5
  • Git client
  • Full Trust Level
  • Visual studio with Razor generator tool: required for pre-compiling Razor views.

Install instructions

  • Ensure all pre-requisites are installed.
  • Clone the Git repository to your local disk. Use git@github.com:devbridge/BetterCMS.git for cloning.
  • Add the following line to the hosts file (it should be edited in Administrator mode):
127.0.0.1  bettercms.sandbox.mvc4.local.net

This file can be found in c:\Windows\System32\drivers\etc\hosts and should be edited in Administrator mode.

hosts file

  • Open IIS Manager. Right click on "Sites" and choose "Add Website":

IIS: add website

  • Enter these values: Site Name: bettercms.sandbox.mvc4.local.net Physical path: browse \Sandbox\BetterCms.Sandbox.Mvc4 folder in the cloned project directory Host Name: bettercms.sandbox.mvc4.local.net

IIS website settings

  • Go to "Application Pools", find the pool bettercms.sandbox.mvc4.local.net and check if the .NET Framework version is v4.0:

IIS: application pool

  • If the current version is not v4.0, double click on your pool and choose .NET Framework v4.{xxxxx} from the .NET frameworks list.

Application pool: .NET framework version

  • Open a project in Visual Studio or Visual Studio Express.
  • Create a database in SQL Server or SQL Server Express and ensure "Application Pool Identity" has read/write access to that database. To read more on this fix, visit troubleshooter.
  • Open BetterCms.Sandbox.Mvc4\Config\connectionString.config for editing and enter the connection string. Read more about connection strings here.

Edit connection string

  • Ensure, that BetterCms.Sandbox.Mvc4 project is set as the start-up project (it should be displayed in bold). If it's not, press the right mouse key on the project and select "Set as StartUp Project".

Set project as startup project

  • Run the solution by pressing "F5" or navigating to "Debug -> Start Debugging". If the database and ISS server are configured correctly, the website will create it's database structure. It could take some time, so please be patient. Eventually, Better CMS should open it's home page. Better CMS is running and content can be edited.

Razor generator tool

From the version 1.8.0, pre-compiled views are used. The Razor generator tool should be used for generating .cs files from .cshtml files. The Razor generator tool can be downloaded here: http://visualstudiogallery.msdn.microsoft.com/1f6ec6ff-e89b-4c47-8e79-d2d68df894ec

Razor Generator's generated .cs file

When a save is performed, EditSeo.cshtml, EditSeo.generated.cs is updated.

If a new Razor view is to be created, Build Action should be set to None and Custom tool should be set to RazorGenerator (in file properties):

File properties with Razor Generator tool

Otherwise, the view will not be pre-compiled and will not be found when running the module.

You can read more about using Razor generator here: http://blog.davidebbo.com/2011/06/precompile-your-mvc-views-using.html

Troubleshootings

Database is inaccessible to application pool's identity

By default, when the application pool is created, ApplicationPoolIdentity is chosen as the pool's identity. It can be changed to another user, for example, "NetworkService". Open "IIS -> Application Pools" and select the application pool bettercms.sandbox.mvc4.local.net. From the context menu (or from the menu on the right) choose "Advanced Settings...". Find "Identity" and press the "Browse" button next to it. Change the built-in account to "NetworkService".

Change application pool identity

Open the SQL Server Management studio. In the object explorer, expand "Security" and "Logins". If there is no NT AUTHORITY\NETWORK SERVICE, add it by choosing "New Login" from the context menu.

New login

Enter NT AUTHORITY\NETWORK SERVICE as login name, keep Windows authentication mode checked.

New login form

Open the "User Mapping" page, select your database and ensure that db_owner and public checkboxes are checked.

User mappings

Press "OK" and try reloading the page. Now the NetworkService account has access to the database and Better CMS should run correctly.

Clone this wiki locally