-
Notifications
You must be signed in to change notification settings - Fork 0
Deployment Project Setup
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.
-
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 -->
-
Make sure
DnnLocalDeployPath
property in__Settings.targets
for your OS contains valid DNN install path andMainProjectName
property contains valid main project name. -
Make sure that
MainProjectOutputPath
property__Settings.targets
contains valid output path for main project - in some cases it could bebin/$(Configuration)
, not justbin
! -
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.
-
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 & 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 -->
-
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. -
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.
-
Module projects require R7.Dnn.Extensions library installed. Get install package from here, go to Host > Extensions on your DNN website and install it.
-
Then install your newly created extension from install package in the same way.
-
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.
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:
-
Name your project file with the
{{SolutionName}}
prefix like{{SolutionName}}_MyNewExtension
. -
Set new project output path the same as for main project output path. Generally it will be
../{{SolutionName}}/bin
or../{{SolutionName}}/bin/$(Configuration)
. -
Merge new project’s
.SqlDataProvider
files,.dnn
manifest file (plus all files, referenced in the manifest - generally, it’slicense.htm
andreleaseNotes.htm
) contents into the similar files from main project.