How to set up development environment

From Sense/Net Wiki
Jump to: navigation, search
  •  
  •  
  •  
  •  
  • 100%
  • 6.0
  • Enterprise
  • Community
  • Planned

Overview

The easiest way to start developing under Sense/Net is to install Sense/Net, create a new custom project of class library type, build your project and copy the built dll-s of your custom project to the webfolder of your Sense/Net installation. However, when it comes to putting the solution into source control and creating a re-deployable solution that also handles Content Repository resources correctly, this process is not adequate. We have developed a simple way to create new Sense/Net development environments for custom projects. This article guides you through setting up the recommended development environment for custom Sense/Net solutions.

Steps

1. Build Sense/Net source

You will need the source package of Sense/Net ECM. Download the latest zip from CodePlex, decompress it and build it with Visual Studio 2013.

The public CodePlex page above offers Sense/Net ECM Community Edition. Customers who have access to the Enterprise Edition should use that source package. For differences between the two editions, please visit the following article:

Install MSBuild Extension Pack

If you did not install this package previously, please download and install it, as it is a prerequisite for building the Sense/Net ECM solution.

2. Create a new web application

Open Visual Studio 2013, create a New Project, and select ASP.NET Empty Web Application. Make sure you put the solution under a folder called Source as we will have other top-level folders, too:

Creating new web application
Name MyWebApplication
Location c:\development\MyWebApplication\Source
Solution name MyWebApplication
Create directory for solution Yes
New ASP.NET Web Application

3. Copy the Web.config of Sense/Net

Copy and paste the contents of the Sense/Net Web.config into the Web.config of your new webapp. You can remove the .Debug and .Release Web.configs, we will not use them now. Set the connectionstring in your Web.config to point to the database that will be created soon:

<add name="SnCrMsSql" connectionString="Data Source=.;Initial Catalog=MyWebApplicationDb;Integrated Security=True;" providerName="System.Data.SqlClient"/>

4. Add App_Browsers and Global.asax

Copy the App_Browsers folder (with contents) and the Global.asax file to your webfolder and add them to your webapp. These are necessary for your custom Sense/Net solution to be working. Use the Show All Files function in VS2013:

Show All Files

Then right click on the App_Browsers folder and Global.asax file you have copied in the directory and select Include In Project.

5. Add config files

Copy the following config files from Sense/Net source's Tools folder and add them to your project next to the Web.config. It is recommended to build your Sense/Net source, so you don't have to bother with renaming app.config files:

  • Export.exe.config
  • Import.exe.config
  • IndexPopulator.exe.config

For the above files set the Copy to Output Directory property to Copy always, so that the referenced console applications' config files will be overridden by ours when we build the project:

Copy always

Set the connectionstring in your .config files to point to the database that will be created soon:

<add name="SnCrMsSql" connectionString="Data Source=.;Initial Catalog=MyWebApplicationDb;Integrated Security=True;" providerName="System.Data.SqlClient"/>

6. Create Code and Root folders

We will place all code (.cs) files in the Code folder (if not in separate dlls) and all Content Repository items that are not part of the default install in the Root folder. Your solution now should look like the following:

Initial solution

The 'Root' folder contains content that will be imported. It is empty, because the example only shows how to set up the initial working environment, from which you can start working on your project. While working you will create new files (ascx, html, etc.), that you will place in the Root folder MANUALLY, and after you've done that you can import these contents to your repository, so that you can work with these contents in your ECMS. Also, you can work with your Root folder the other way around: create content in the repository using Sense/Net ECMS, then export the created content to your solution's Root folder, and check them into the TFS so that your colleagues can import those into their repository.

7. Reference Sense/Net dlls

Create a folder for the Sense/Net core dll references on the same level as the folder Source, call it SenseNetReferences, and copy all dlls from the Sense/Net webfolder bin. Copy there Import.exe, Export.exe and Indexpopulator.exe from Source\SenseNet\WebSite\Tools\, as well. From your new folder reference the following files into your web app:

  • Export.exe
  • Import.exe
  • Indexpopulator.exe
  • Microsoft.Practices.EnterpriseLibrary.Logging.Database
  • Microsoft.Web.Preview.dll
  • SenseNet.ContentRepository.dll
  • SenseNet.CorePortlets.dll
  • SenseNet.OldPortlets.dll
  • SenseNet.Portal.dll
  • SenseNet.Storage.dll
  • SenseNet.Workflow.dll
  • SenseNet.Workflow.Definitions.dll
  • SenseNet.Workflow.Design.dll

8. Prepare db scripts

Create a Deployment folder on the same level as the folder Source. Create a folder under it, name it sql, and copy the following .sql files from Source\SenseNet\Storage\Data\SqlClient\Scripts\:

  • Create_SenseNet_Database.sql
  • Install_Security.sql
  • Install_01_Schema.sql
  • Install_02_Procs.sql
  • Install_03_Data_Phase1.sql
  • Install_04_Data_Phase2.sql
  • SqlWorkflowInstanceStoreLogic.sql
  • SqlWorkflowInstanceStoreSchema.sql

Open Create_SenseNet_Database.sql and replace SenseNetContentRepository with MyWebApplicationDb everywhere - it will be the name of your database.

SQL scripts

9. Copy Sense/Net Root

Copy the Root folder (Source\SenseNet\WebSite\Root ) of your Sense/Net source to a new folder on the same level as your Source folder, and name this folder SenseNetRoot. This SenseNetRoot folder should contain the Root folder and below it every content of the default Content Repository.

10. Create deployment batch files

Go to your Deployment folder and create a batch file called InstallMyWebApplication:

ECHO OFF
 
SET DATASOURCE=.
SET INITIALCATALOG=MyWebApplicationDb
 
sqlcmd.exe -S %DATASOURCE% -i "sql\Create_SenseNet_Database.sql"
sqlcmd.exe -S %DATASOURCE% -d %INITIALCATALOG% -i "sql\Install_Security.sql"
sqlcmd.exe -S %DATASOURCE% -d %INITIALCATALOG% -i "sql\Install_01_Schema.sql"
sqlcmd.exe -S %DATASOURCE% -d %INITIALCATALOG% -i "sql\Install_02_Procs.sql"
sqlcmd.exe -S %DATASOURCE% -d %INITIALCATALOG% -i "sql\Install_03_Data_Phase1.sql"
sqlcmd.exe -S %DATASOURCE% -d %INITIALCATALOG% -i "sql\Install_04_Data_Phase2.sql"
sqlcmd.exe -S %DATASOURCE% -d %INITIALCATALOG% -i "sql\SqlWorkflowInstanceStoreSchema.sql"
sqlcmd.exe -S %DATASOURCE% -d %INITIALCATALOG% -i "sql\SqlWorkflowInstanceStoreLogic.sql"
 
 
REM import Sense/Net default Content Repository
..\Source\MyWebApplication\MyWebApplication\bin\Import.exe -SCHEMA ..\SenseNetRoot\Root\System\Schema -SOURCE ..\SenseNetRoot\Root -TARGET /Root -ASM ..\Source\MyWebApplication\MyWebApplication\bin
 
REM import MyWebApplication Content Repository without CTDs
..\Source\MyWebApplication\MyWebApplication\bin\Import.exe -SOURCE ..\Source\MyWebApplication\MyWebApplication\Root -TARGET /Root -ASM ..\Source\MyWebApplication\MyWebApplication\bin\ 
 
REM import MyWebApplication Content Repository with CTDs
REM ..\Source\MyWebApplication\MyWebApplication\bin\Import.exe -SCHEMA ..\Source\MyWebApplication\MyWebApplication\Root\System\Schema -SOURCE ..\Source\MyWebApplication\MyWebApplication\Root -TARGET /Root -ASM ..\Source\MyWebApplication\MyWebApplication\bin\ 
 
REM build index files
..\Source\MyWebApplication\MyWebApplication\bin\IndexPopulator.exe
 
ECHO Done.

The above batch file will create the MyWebApplicationDb database on your local machine (.), and import first the default Content Repository and then import your own Content Repository items over it.

If you define custom CTDs, don't forget to use the -SCHEMA argument for the Import.exe. In the above batch file we have commented out the line that imports your custom structure with CTDs, since that path does not exist yet.

11. Overview the structure

The created file/folder structure should look something like that:

Created File/Folder structure

12. Bind files to source control (optional)

If you plan to work collaboratively with your colleagues, it is recommended to put the above structure into source control. This setup comes very useful when a new developer is brought into your team and will start working together with you on this project. He/She will only need to get the latest version of your project from source control, build it, execute InstallMyWepApplication.bat, and he/she will immediately have a fully functional running Sense/Net with your customizations and extensions.

13. Rebuild and install

Rebuild your solution and start InstallMyWepApplication.bat.

14. Set up IIS site

The last step is to set up an IIS site for your web application. If you don't already know how to do it, please go through steps 3 and 4 in the following guide (your website path is c:\development\MyWebApplication\Source\MyWebApplication\MyWebApplication - where your web.config file is located):

To run your new empty web project, simply request the corresponding url you have set in the IIS, like http://localhost, and the main screen of your ECMS should appear.

Related links

References