Automated DotNetNuke Module Packaging MSBuild

本文介绍如何通过修改项目文件并利用MSBuild及其社区任务扩展来自动化打包DotNetNuke模块。文中提供了具体步骤及示例代码,帮助开发者简化模块打包流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文转自:http://www.dnnsoftware.com/wiki/Page/Automated-DotNetNuke-Module-Packaging-MSBuild

       

    You can easily auto package your modules by making a few changes to the vbproj (or CSPROJ for C#) file for your project. Packaging your module is really just zipping up the correct files. You can do this with MSBuild by using the MS Build Community Tasks extension. Download it and install it from https://github.com/loresoft/msbuildtasks/downloads . Once you have that installed its a simple case of editing the vbproj file. To do this in Visual Studio:

  • Right click the project name in Solution Explorer
  • Select Unload Project
  • Right click the greyed out project name in Solution Explorer again
  • Select the Edit option.
    You will now see the MSBuild file for your project.  All of the modules and providers in the DotNetNuke Core project have this modification.  To see this modification you will have to use the source code in the CodePlex source tree as the pacakges distributed in the Source package have this modification removed because it relies on the MSBuild Community tasks being installed and it also causes a security prompt the first time it loads the project.
    The example code below is for the HTML Module.  Since all modules need to be packaged it makes sense to have a generic packaging script and just pass variables to it.  If you look at the HTML Module vbproj file you will a property group section like this:
     
    <PropertyGroup>
    
    <Extension>zip<Extension>
    
    <DNNFileName>dnn_HTML</DNNFileName>
    
    <PackageName>HTML_Community</PackageName>
    
    <MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\..\..\BuildScripts</MSBuildCommunityTasksPath>
    
    </PropertyGroup>


  • The next line
    <Import Project="..\..\BuildScripts\ModulePackage.Targets" />
    Imports the generic packaging script from the file ModulePackage.Targets.  The next line tells MSBuild to execute the packaging after the build is completed.
    <Target Name="AfterBuild" DependsOnTargets="DebugProject;PackageModule"></Target>

    This line tells MSBuild to execute both the DebugProject and PackageModule tasks, DebugProject is actually in the vbproj file below but the PackageModule task is in the imported build file.  The DebugProject task simply copies files to the root website so you can debug.  The PackageModule task firstly Imports the MSBuild Commumity tasks so we can use the Zip task and the XmlRead task.  This task is only executed when in Release mode.
    Then I use XmlRead to read the version of the module out of the .dnn file. 
    <XmlRead Prefix="n"
    
    Namespace="http://schemas.microsoft.com/developer/msbuild/2003"
    
    XPath="dotnetnuke/packages/package/@version"
    
    XmlFileName="$(DNNFileName).dnn">
    
    <Output TaskParameter="Value" PropertyName="Version" />
    
    </XmlRead>
    
    


This is then used later to name the package correctly.

Note: If working with a package that contains multiple sub-packages change the xpath to be "dotnetnuke/packages/package 1/@version" which will use the FIRST version number for the package.

Next we find the files we need and copy them to a Package folder.  Note that at DNN Corp we use a standard way to arrange our modules so we can use the same script across the modules. Now that we have all the files in the package folder we use the Zip task to zip all the files up and then create an Install zip file.  Lastly we delete any copied or created folders.  The nice thing about doing it this way is you don't need to execute any external program to do your build, you simply switch to Release mode and hit build.  The install zip is then created and dropped into the Website/Install/Modules folder ready to install.

Examples»

Christoc's DotNetNuke Module Development TemplateFor examples on using MSBuild to package modules check out the 00.00.05 release of the module development templates found at http://christoctemplate.codeplex.com

MS Build for DotNetNuke module developmentThis extension forge project automates the task of creating DotNetNuke module PA and Source packs using MS Build. This MS Build tasks will generate DNN manifest files (.dnn files for DNN 5.x), it will process and generate version #'s, all file updates, release notes, clean up and much more. In addition to packaging, all .js and .css are minified before putting them in the Install pack, for optimal performance. The original .js and .css files remain untouched. MS Build for DotNetNuke module development
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值