Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Deployment Project Setup

Roman M. Yagodin edited this page Feb 10, 2018 · 4 revisions

Initial setup of deploy project

The deployment project template use MSBuild to create install packages and deploy files to DNN install location, but due to template engine limitations it will require some changes to be made manually in a project file.

  1. Open deployment project file (e.g. Deploy.csproj) in a text editor and insert following code just after last <Import Project="…​"> tag:

<!-- Begin snippet -->
<Import Project="__Settings.targets" />
<Import Project="__Defaults.targets" />
<Import Project="Tests.targets" />
<Import Project="LocalDeploy.targets" />
<Import Project="InstallPackage.targets" />
<Target Name="AfterBuild" DependsOnTargets="Tests;LocalDeploy;InstallPackage" Condition=" '$(EnableAfterBuild)' != 'false' " />
<!-- End snippet -->
  1. Make sure DnnLocalDeployPath property in __Settings.targets for your OS contains valid DNN install path and MainProjectName property contains valid main project name.

  2. Make sure that MainProjectOutputPath property __Settings.targets contains valid output path for main project - in some cases it could be bin/$(Configuration), not just bin!

  3. Add reference to the main project. This will ensure that deployment project won’t start in case of build errors in the main project and also that deploy project will build last.

  4. Optionally, to enable custom build commands from deployment project context menu, insert following code inside the <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> tag in the project file (replace {{SolutionName}} with the name of your solution):

<!-- Begin snippet -->
<CustomCommands>
    <CustomCommands>
        <Command>
	    <type>Custom</type>
	    <name>Build Only</name>
	    <command>msbuild /t:Build /p:Configuration=${ProjectConfigName} /p:EnableAfterBuild=false ../{{SolutionName}}.sln</command>
        </Command>
        <Command>
	    <type>Custom</type>
	    <name>Build &amp; Deploy</name>
	    <command>msbuild /t:Build /p:Configuration=${ProjectConfigName} /p:EnableTests=false /p:EnableInstallPackage=false /p:EnableLocalDeploy=true ../{{SolutionName}}.sln</command>
	</Command>
        <Command>
	    <type>Custom</type>
            <name>Re-deploy</name>
	    <command>msbuild /p:Configuration=${ProjectConfigName} /p:EnableTests=false LocalDeploy.targets</command>
	</Command>
        <Command>
	    <type>Custom</type>
	    <name>Make Install Package</name>
            <command>msbuild /t:Build /p:Configuration=${ProjectConfigName} /p:EnableTests=true /p:EnableInstallPackage=true /p:EnableLocalDeploy=false ../{{SolutionName}}.sln</command>
	</Command>
	<Command>
	    <type>Custom</type>
	    <name>Run Tests</name>
	    <command>msbuild /t:Build /p:Configuration=${ProjectConfigName} /p:EnableTests=true /p:EnableInstallPackage=false /p:EnableLocalDeploy=false ../{{SolutionName}}.sln</command>
	</Command>
    </CustomCommands>
</CustomCommands>
<!-- End snippet -->

Testing deployment project setup

  1. Switch to Release configuration and execute Build All command. After this in a bin/Deploy folder of deployment project you should find a .zip archive with install package.

  2. Switch to Debug configuration and execute Build All command. This will invoke local deployment script, which will copy new binaries and required resource files (such as .ascx, .cshtml, .resx, .js, .png etc.) to your DNN install location.

Initial setup of DNN installation

  1. Module projects require R7.Dnn.Extensions library installed. Get install package from here, go to Host > Extensions on your DNN website and install it.

  2. Then install your newly created extension from install package in the same way.

Further development

  • Use Debug configuration to do local deploy after making code changes, then update your site in a browser to trigger recompilation.

  • Use Release configuration to build install package.

  • If you added custom build commands, you can invoke Re-deploy command to deploy modified project files to DNN install, including modified binaries. This will save you a bunch of time.

Extending solution

Current scripts automatically able to add all DNN projects inside solution into a single install package and provide local deployment of required files. The general idea behind that is that all projects in the solution share same root namespace.

If you add new DNN extension to your solution using R7.Dnn.Templates, you probably only need to:

  1. Name your project file with the {{SolutionName}} prefix like {{SolutionName}}_MyNewExtension.

  2. Set new project output path the same as for main project output path. Generally it will be ../{{SolutionName}}/bin or ../{{SolutionName}}/bin/$(Configuration).

  3. Merge new project’s .SqlDataProvider files, .dnn manifest file (plus all files, referenced in the manifest - generally, it’s license.htm and releaseNotes.htm) contents into the similar files from main project.

General tips

  • If .targets files changed manually, you probably need to unload/reload deployment project.

Clone this wiki locally