Simple answer, how to create a module in VS2012?

Topics: Customizing Orchard
Jan 18, 2013 at 2:16 PM
Edited Jan 18, 2013 at 2:18 PM

There are some docs on the Internet, i.e 

  • Create a Hello World module in Orchard;
  • Create a simple Text Editor module in Orchard.

But they are not using Visual Studio.


My question is, how to create a module in Visual Studio? Do we have a template to do so?

The process I found (not sure if they are all correct):

1. Download source code of Orchard;

2. Open .sln in Visual Studio;

3. Run the Orchard.exe command line (codegen module) to create a module (can't we do it directly in VS??):

4. What's next? How to add the business logic in my custom module?


Many thanks!


Jan 18, 2013 at 3:02 PM
Edited Mar 17, 2015 at 3:47 PM
Jan 18, 2013 at 3:04 PM

Business logic is implemented as C# classes in your module. You can put these classes anywhere you like, although we typically create them in a "Services" folder to separate them from the controllers, models, drivers, etc. If you look at the existing modules you'll find a vast array of examples.

Jan 18, 2013 at 7:15 PM

Thanks mate,

So OK with the command line, however do I have to build the whole Orchard src solution in order to develop/debug my own little module?
Can't we just create a empty MVC 4 solution and then add Orchard DLLs and then build or solution, then publish/release to the Orchard module list? (something like that...) 

Jan 18, 2013 at 7:23 PM

You don't have to, but it will be difficult to testdrive your module without the Orchard.Web (unless you do TDD).

Question: why would you want to create an empty MVC 4 solution instead of working with the solution that comes out of the box?
If it's because the vast number of modules, you could probably remove most of them.

Jan 18, 2013 at 7:23 PM

You don't have to build anything, no, you can let dynamic compilation build your module for you. However, if you have Visual Studio, it's way more comfortable to work with the full source code and build yourself.

Jan 18, 2013 at 8:00 PM

Thanks guys, the reason I asked that was because: I just want to develop a small custom module ,and then enable it in my Orchard website.

So I found I have to work inside the Orchard src solution\Modules\MySmallCustomModule, and everytime I will have to CTRL-F5 to run Orchard, then I can test my module.  Don't you feel it's not very comfortable? :) 

Jan 18, 2013 at 8:05 PM

Mmmh, no. How would you see it work that would be more comfortable? FWIW, for the sites I work on most often, I configure IIS instead of letting VS spawn a dev web server.

Jan 18, 2013 at 8:10 PM
Edited Mar 17, 2015 at 3:46 PM
And in addition, pressing F6 will build just the changed projects (hit CTRL + F6 to build just the current module). ALT + TAB to your browser and hit refresh.
Jan 18, 2013 at 8:31 PM
Edited Mar 17, 2015 at 3:46 PM
I actually meant "shift + F6".
Mar 17, 2015 at 12:42 PM