Archive
Monthly
Go
|
|
DNN Blog
Mar
1
Posted by:
Benoit Sarton
2009-03-01 05:59:54Z
Several interesting posts or blogs have been published, explaining how to start a new module for DNN. Among them, Todd Davies, Vincenç Masanas, Michael Washington and Vladan Strigo have greatly helped the community. Gilles, my co-lead in the Store Project, has forged his very own method to setup a new project, trying to pick up the best from each of them. Please search these blogs and forums, and read our venerable predecessors also, since no single solution can meet all needs. This one is probably one of the best compromise, and it is perfect for large projects, as well as simple mono-project modules.
In the scope of this blog, we will only consider the WAP model. This should not be a problem anymore, since the compiled build model has been added to Visual Studio Express with SP1.
Expected benefits from this method
Our goal is to set up a Visual Studio development environment where we would just have to ‘generate the solution’ in order to obtain:
- – the latest changes immediately reflected in the test website ;
- – possibility to debug and trace step-by-step. (although the wap model will not permit to go as far as edit & continue);
- – a package almost ready to be shipped as a regular DNN module after every rebuild (packaging a module is out of the scope of this article, but I will give a few hints about that in step 15 below);
We don’t want to have the whole DotNetNuke solution rebuilt every time though, because this takes time. Keeping the solution light was another requirement.
Prerequisites
We assume that you have a working DNN website up and running, and VS 2005 or VS 2008 pro installed. This should work with VS 2008 express with SP1 and using the WAP model, but we have not tested it yet – feedbacks are welcome.
Note that you do not need a source version of DotNetNuke installed, although it might be usefull to have immediate access to the source of many objects that you will use in your own code sooner or later. On the other hand, if you choose to install a source package of DNN, there will be no negative impact on build performances, thanks to the trick explained at step 11. As developers, installing the core with sources will therefore be our preferred choice.
So let’s go for a simple project
Let’s create a new module. In this blog I will demo with a simple module, which contains a unique project. If there is a positive feedback, we will explain in a future blog how this method can be adapted to multi-module projects like DNN Store.
Since our module will be made of a single Visual Studio project (which will also be the unique project of a ‘Visual Studio solution’), let’s give all these entities the same name: MyNewModule. When we adapt this method to the store module, we will need more elaborate naming conventions, because Store is, in fact, a set of several ‘dnn modules’ (cart, catalog, etc), each of them built with several Visual Studio Projects (where the ‘dnn modules’ do not line-up with the ‘VS project’). That said, apart the naming convention that is simplified here, the basic principles of Gilles’s method can be adapted to setup more complex solutions.
To make it simple here, we will create a Visual Studio solution “MyNewModule”, in the Windows folder “Website\DesktopModules\MyNewModule” of our DNN installation. This solution will contain a single project, named “MyNewModule” and generate a DNN module, also named “MyNewModule”.
Step-by-step installation
- Open Visual Studio without any solution or project. Your solution explorer is completely empty.
- File/open/website (or Maj+Alt+O). This opens a window to select your DNN website in the ‘Local IIS server’ list. Select it.
- Rename the solution ‘MyNewModule’
- In the solution explorer, note the line below solution ‘MyNewModule’, starting with http://localhost/DotNetNuke_2 (or whatever name you gave you site in IIS). More on this later.
- Right-Click Solution ‘MyNewModule’ and add a new project (or File / Add / New project)
- Select DotNetNuke Compiled Module. Name it MyNewModule and make sure that the path ends with \Website\DestkopModules. Suppress the trailing \MyNewModule from the path, otherwise you will get a folder inside a folder like Russian puppets.
- Your solution should now contains 2 projects : a ‘web site’ named something like http://localhost/DotNetNuke_2 ; and your actual project named MyNewModule
- Click once over Solution ‘MyNewModule’ to enlight it, and save it.
Setting the properties for the ‘website project’
9. RightClick the website project (the line starting with http://localhost/etc in you solution explorer), and select the properties page. The first two tabs there are ‘References’ and ‘ generate build'
- Select References, Add a reference, Projects. You should find MyNewModule there. Add it. This will trigger a post-compilation action that will automatically copy our project dll into the general website \bin directory, after every build. This step is a key point in Gilles’s technique since it will save you countless copy and paste of the dll after every build. It tells Visual Studio that the website needs the ‘MyNewModule’ dll, so after every build it will copy it into the \bin directory. And this is exactly what we want, so we can test and debug our newly compiled module in our DotNetNuke website, live.
- Select
‘generate’ 'build' and unclick ‘ generate build the website with the solution’. You should also set the action before start to ‘Do not generate build’. All this means that we have only included the website in our solution in order to obtain some automation when we rebuild our modules, but we do not want to regenerate the website itself since this is not what we are developing for (note : the term 'generate' was an incorrect back-translation from the french for 'build'.
- Set the website as the start project. You may find it strange to start with the project that we do NOT want to
generate build ? The reason is that in a DotNetNuke website, it does not make sense to start a module without opening a portal. We always open the DNN website first, and from there it will execute our module. Somehow, running the website is a prerequisite to running our module.
Setting the properties for ‘MyNewModule’ project
- Open the properties page for MyNewModule project. The tabs there are Application, Compiler, References, Ressources, Parameters, Signature, Extensions My (VS 2008) and Web.
- Application: set the assembly name to MyCompany.Modules.MyNewModule
and the root namespace to MyNewModule (or leave the namespace empty) (Edit: in C# you may keep the namespace 'MyNewModule', but in VB.NET leave it empty). When developing a core module like Store, MyCompany would be DotNetNuke. So if you have Store installed, and look into you Website\bin directory, you will find files like DotNetNuke.Modules.Store.Cart.dll
- Compiler: generation events / post build. This point is optional and you can step over if your project is not for distribution. If you want to make it an installable module, it is here that you can get the copy and paste chore done for you. You will typically add here the copy commands that will flatten all the files hierarchy from your project to the dedicated package folder where they will be zipped together: ascx, images, dll, documentation, etc). If any file add been added or deleted since the previous build, you would still have to edit the manifest by hand. Have a look at the Store solution to check out how Gilles uses this technique to automate the packaging of a module that is made of many projects.
- References : add a reference , browse and add DotNetNuke.dll. Uncheck ‘local copy’. Unchecking the local copy is a time and disk space saver, that will avoid multiple and useless copies of DotNetNuke’s dlls into your projects folders.
- Web : Use the local web server and set the project URL to something like : http://localhost/DotNetNuke_2/DesktopModules/MyNewModule and replace the application root URL to : http://localhost/DotNetNuke_2 (or whatever). This will allow working in design mode as well as code view. If you skipped this step, your source files would be unable to resolve the tilde (~) and find their roots.
- Generate the solution.
Done. You can now install the generated module into your DNN website, test it, and the next time that you change your codebehind (and, of course, any ascx or resource files), the changes will be reflected into you local website with a single refresh.
You can also set breakpoints into your code, and press F5 to compile, run and debug the module from Visual Studio.
Gilles le Pigocher and myself hope that this method will be helpful, and we will be very pleased to read your comments, suggestions and improvements.
21 comment(s) so far...
Re: Setup a VS project to create or modify a DNN module - the Store team method
Great post. Thankyou!
By Alex Shirley on
2009-03-01 17:11:08Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Great post! I was working on a completely different issue and found your post from a few hours ago.
Thanks and keep up the great work!
By Dwayne Baldwin on
2009-03-02 01:43:01Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Great Great Great Post !!!
It reveals many hidden secrets :)
By Jaydeep Bhatt on
2009-03-02 08:46:30Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Very nice solution, Adding the final part to create the build package automatically makes this even better. Will have to take a look at the Store module so see how that functionality is used.
By Shawn Mehaffie on
2009-03-03 06:18:25Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
I think there are some prerequisites that are not explained. For example, I have a DNN 4.7.0 site running as localhost/dotnetnuke4 on my WinXP IIS5 machine, and I am using VWD 2008 SP1, and when I attempt to open the website localhost/dotnetnuke4 (your step 2) I get errors about Front Page Server Extensions. Also I have installed the DNN 4.7 Starter Kit and yet I don't see the option for DotNetNuke Compiled Module (your step 6) in VWD 2008. Can you say what all the prerequisites are for the development environment?
By Laurence Neville on
2009-03-03 13:53:14Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
WHOW!!! very interesting.... looked for times..... thanks!
By rmartin77 on
2009-03-03 18:35:59Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
@Laurence : If you can't open a web site from Visual Studio, it's probably because something is wrong with your configuration. Could you give me more detail about the Front Page Server Extentions error? The prerequises are those nedded by any dnn instance (XP Pro, IIS 5, Visual Studio). Are you able to create a new dnn instance from the starter kit?
Gilles
By Gilles Le Pigocher on
2009-03-05 02:06:51Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
@Shawn: Basicaly it's just the use of some copy commands in the post build event section of each project. The idea is to create a folder like ..\DesktopModules\MyModule\MyPackageFolder, then add commands like copy $(ProjectDir)*.ascx $(SolutionDir)MyPackageFolder. This one will copy each ascx files from your project folder to the package folder. After each build the folder 'MyPackageFolder' contains all needed files to create your PA. You just have to edit the manifest file to reflect your changes (new controls, images, ..). Visual Studio is able to automate many things but not to create the manisfest nor to make coffee! ;-) Please read this post before trying to install the source version of the Store module: www.dotnetnuke.com/Community/Forums/tabid/795/forumid/114/threadid/186305/scope/posts/Default.aspx, you will save hours!Gilles
By Gilles Le Pigocher on
2009-03-05 02:30:42Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Benoit... on Step 11. I'm not finding where you're talking about this in VS 2008. Can you give me a point in the right direction?
By Mike Horton on
2009-03-06 21:45:38Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Mike, if followed this method step by step you have 2 projets in your solution. One is the website localhost/your_iis_website, the second one is your actual projetct (and future dnn module).
On step 11 you right-click http//localhost/your_iis_website , select properties page. Then the second choice in the list (below References) is 'generate'. in the listbox (starting actions F5 ; before execute start page), select 'do not generate) ; and just below there is a checkbox 'generate the web site for the solution' ; you UNcheck this option.
Unfortunately my VS Studio has been set in french, so I hope that my translations into english make sense in your VS 2008 install. The wordings might not be exactly the same.
By Benoit Sarton on
2009-03-06 22:56:37Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Thanks Benoit. That pointed me in the right direction. In the English version it's called Build instead of Generate.
By Mike Horton on
2009-03-07 18:55:30Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Thanks for the tutorial, I've created a page in my wiki that describes these steps but in VS2005 with an installed DNN 4 on a local web server.
www.ericduhaime.com/wiki/pmwiki.php/Programmation/StepByStepSetupOfVS2005Project
By EricDuhaime on
2009-03-10 16:30:18Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
In the new module, how do you make use of DNN user controls (texteditor, labelcontrol, etc) ? When I edit in design mode, it doesn't find the ascx controls since they're located in the website project.
By Stephen on
2009-03-17 17:53:33Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
@Stephen: If the controls are not correctly rendered it's because you left someting from the step #17. This step is the key point to "tell" to VS how to resolve the ~.
By Gilles Le Pigocher on
2009-03-20 16:05:17Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Thank you for your feedback. This month I will invite you to discover Entity Framework with DotNetNuke and the Store module, and I hope to meet you there.
By Benoit Sarton on
2009-04-01 20:16:48Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Please explain the multi module solution.
By ech01 on
2009-05-21 22:35:34Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Please explain the multi module solution.
By ech01 on
2009-05-21 22:41:02Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
I have made my new module. I have installed a new dotnetnuke website and add to the main solution a prohect that is my module.
Hi have followed this toutorial
But Hi have my module/project that have the default directory in /DesktopModule/Modulename (see the photo below) this create a lot of problem, for example a lot of lables have the same error: Error 2 Name 'lblUserId' is not declared. C:\siti\xxxx\xxxx\DesktopModules\GyniusAdm\ElencoMacchine.ascx.vb
But the lable exist, i this that is possible tha visualstudio doesen't find correctly the items.
1) How do you create your module, its correct this way? img189.imageshack.us/img189/1075/cattura.gif thanks Rmartin
By rmartin77 on
2009-06-19 16:50:24Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Hi,
Great article:) - Thank you, but.......
Is it possible to set this up using the visual studio web server (cassini) instead of iis?
I think step 17 would need modifying, but i'm not sure what to enter for the project and application root url.
My cassin url is LocalHost:1374/MyWebSite/Default.aspx
Can this be acheived?
Any help appreciated.
Regards,
Paul
By Paul Wade on
2010-05-31 21:26:29Z
|
Re: Setup a VS project to create or modify a DNN module - the Store team method
Paul, the method described in this blog is for use with the WAP model.
As far as I know, one of the reason to use Cassini would be 'Edit in place', but this feature is not available for WAP projects.
Therefore, I don't know why someone would use Cassini rather than IIS, except that IIS is not included with xp home if that is the reason ?
Sorry I can't tell more about Cassini since I have never used it.
By Benoit Sarton on
2009-12-10 18:51:26Z
|
Visual Source Safe?
My solution contains the DNN website plus my bespoke WAP projects.
I would like to have my WAP projects under source control (VSS), but not the DNN website. Is this possible?
Whenever I add a WAP project to VSS, it tries to include the whole DNN website.
Any help appreciated.
Regards,
Paul.
By Paul Wade on
2010-05-31 21:26:47Z
|
|