Late last year I created a blog post and video about a new version of the module development template that I released on CodeplexGitHub. This new template uses MSBuild scripts instead of NANT scripts to automate the packaging process for the modules built with the template.
The MSBuild script works well out of the box, to package your module you simple change into RELEASE mode and then execute the build.
If your project contains references to DLLs (in the website’s BIN folder) that you also need to package up so that you can deploy them with the module however things become a little murky. Earlier today Bruce posted on that original blog post asking how to include those DLLs in the build script so they get packaged automagically.
I thought this would be easy, simply add a new line to the MS Build file for the DLL (two actually so that you can target both the INSTALL and SOURCE packages that get built). The existing DLL gets pulled in with the following line (this line is found twice in the modulepackage.targets file)
1: <Copy SourceFiles="$(MSBuildDnnBinPath)\$(AssemblyName).dll" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>
So you would think adding another one would simply be
1: <Copy SourceFiles="$(MSBuildDnnBinPath)\$(AssemblyName).dll" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>
2: <Copy SourceFiles="$(MSBuildDnnBinPath)\SOMEDLLNAME.dll" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>
but if you do a build and check the packages you’ll find that the DLL doesn’t get included.
So what gives? It should be that easy. I racked my head on this for a while and figured something out, something I didn’t realize. Visual Studio actually caches the MSBuild file. So if you make changes, and then try to run a build in RELEASE mode you won’t see those changes take effect. What do you have to do? Unfortunately you have to close the project and load it again.
This is definitely a pain, but in the long run as easy as the scripts make packaging of modules I would think that the off times you have to make a change, restarting the project isn’t that big a deal, as long as you remember that fact.
One other thing to remember when you are packaging up a module, you need to tell DNN about the DLL that gets included in the package, you do this by adding a couple of lines to the .DNN manifest file.
For example this
1: <component type="Assembly">
2: <assemblies>
3: <basePath>bin</basePath>
4: <assembly>
5: <name>dnnsimplearticle.dll</name>
6: </assembly>
7: </assemblies>
8: </component>
Becomes
1: <component type="Assembly">
2: <assemblies>
3: <basePath>bin</basePath>
4: <assembly>
5: <name>dnnsimplearticle.dll</name>
6: </assembly>
7: <assembly>
8: <name>SOMEDLLNAME.dll</name>
9: </assembly>
10: </assemblies>
11: </component>
The sample code in this blog post references DNNSimpleArticle which you can download in C# or VB.NET from https://github.com/ChrisHammond/dnnsimplearticle
Good luck, and get coding!