Setting Up Your Own Projects for Custom Development

A Video Introduction to the mojoPortal Source Code - about 20 minutes, requires the free Silverlight  plugin to watch.

The notes here are meant to answer the question: How do I setup my projects so that I can work with mojoPortal from svn trunk and keep my own code in my own repository. Some of this material is also covered in a training video, but the quality of that particular video is not good, hopefully I'll find time to do a better one soon. You might also find this blog post about Creating a mojoPortal Module by Steve Land helpful.

To keep your stuff separate and use your own source control repository is fairly easy.

1. First clone mojoportal  from our source code repository, then copy the mojoportal.sln file from the root folder of the source code into a folder somewhere else on your hard drive. Then rename the file as my-mojoportal.sln (or whatever you like), and finally move the copied/renamed file back into the root folder of the source code. Now you can open your custom .sln file in Visual Studio 2010/2012, and add your own custom projects to that solution.

2. Create your own top level folder named MyProjects (or whatever you like) so that this folder is a top level folder at the same level as the other mojoportal project folders. Create your projects inside the MyProjects folder so you may have something like:

MyProjects/Web.UI (a Web Application Project)
MyProjects/Business (a class library project)
MyProjects/Data.MSSQL (a class library)

Now everything in the MyProjects folder can be managed by your source control and only the .sln file can't be because it lives in the root folder. If you need to share the .sln file with other developers on your team you could make a copy and paste it into your folder, add it to your source control for safe keeping with instructions for others to copy it to the root to use it.

Your Web.UI project must be a Web Application project, but you will never run it directly, you will always debug using the mojoportal web project but you will still be able to step through the code. The trick is to use a post build event to copy the needed files up to the Web folder. Look at the post build event in the WebStore.UI project for an example. You will need to reference the mojoPortal.Web project and other projects like mojoPortal.Business from your Web.UI project

You will also need to have a few things in place to make sure everything compiles ok in your Web.UI project. You'll need to copy the whole pages section from the mojoportal Web.config into your project's Web.config. You'll need to create a folder named App_MasterPages and create a dummy master page there named layout.master. It must have the same content placeholders as the one in the mojoportal web project.

During development you will always be running the mojoportal web project as the main project. You can set breakpoints in your code and debug with no problem but mojoportal web must be the startup project. Working in this mode keep in mind that if you make a change in your .aspx or .ascx files you won't see the change until you build your Web.UI project because its the post build event which will copy your files up to the mojoportal Web folder and the ones there are the ones actually used at runtime.

Within your Web.UI project its best to create a folder to contain all your pages and controls so that this folder is copied up under the mojoportal Web and all of your .aspx and .ascx files are there. So you might have a folder like this:

Web.UI/MyCoolFeature

and when the post build copies it up to the Web folder it lands at:

Web/MyCoolFeature

Try to use a unique name for your folder to avoid future clashes with mojoPortal features. Make sure you don't copy things like the Web.config file from your project up to the mojopotal Web, its not needed there and overwriting the real one will be a problem.

Rate this Content 17 Votes