Developers Knowledge Base

Learn how to manipulate, modify, and tune your GeoMedia WebMap, Geospatial Portal and Consumer portal instances.
Showing results for 
Search instead for 
Do you mean 

MSBuild Script For Creating Custom Templates.

by Technical Evangelist on ‎09-02-2015 06:44 AM - edited on ‎02-20-2019 12:46 AM by Technical Evangelist (1,577 Views)


The build.xml script was created and tested with MSBuild 12.0 only. It may need to be updated if you plan to use it with later versions.


Build.xml is a MSBuild script that compiles Geospatial Portal from the project file present in the SDK, adds language assemblies and necessary local resources and builds a "template" folder that can be then registered in the Geospatial Server Administration Console.


More technically:

  1. Compiles Application.csproj and its dependencies to create web application folder
  2. Copies language files to the web application folder
  3. Copies AdministratorFiles from the default template location
  4. Copies application.xml file from the default template location
  5. Updates //application/name and //application/description properties in application.xml file

After using that script for building the portal, all that needs to be done in order to use the new template is:

  • manually copying the new template from C:\MyTemplates to C:\Program Files\Common Files\Hexagon\Services\Templates\
  • registering the new template by editing C:\inetpub\wwwroot\AdminConsole\App\WorkflowSettings\AdministrationConsole.xml
  • restarting the Administration Console Service

Please make yourself familiar with Creating a new Consumer Portal template to know more technical details. Do not use this msbuild script with Consumer Portal.


The script assumes that:

  • it is copied to the "build" folder. Default folder structure in the package is
    • build
    • src
    • lib
  • Geospatial Server Administration Console Templates are located in
    C:\Program Files\Common Files\Hexagon\Services\Templates\Geospatial Portal\
  • The output folder for the templates is
  • Script assumes that you have Visual Studio at least in 12.0 version, so:
  • You have MSBuild here:
    c:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild

Example usage


The following example will create a template named MyPortal from files located in C:\2015SDK\portal.

Assuming that our SDK files are in C:\2015SDK\portal folder, we need to:

  • Open the Command Line prompt:
    • Windows+R
    • cmd.exe
  • Go to the build folder
    C:\>cd \2015SDK\portal\build
  • Invoke the msbuild command
    C:\2015SDK\portal\build>"c:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild" build.xml /p:MyTemplateName=MyPortal
  • Copy your template to the Administration Console Templates folder



  • After the template is ready, register it in the console:
    • Edit C:\inetpub\wwwroot\AdminConsole\App\WorkflowSettings\AdministrationConsole.xml
    • Copy Geospatial Portal WorkflowNode element
      • Give it unique 'ID', for example 1012
      • Change 'label' to MyPortal Configuration
      • The general pattern in '<TemplateName> Configuration'



Restart the Admin Console Service

  • Windows+R
  • services.msc
  • Geospatial Server Administration Console
  • Restart




<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="" DefaultTargets="BuildProjects">
  <Import Project="$(MSBuildThisFileDirectory)..\build\build-utilities\msbuild\main.targets" Condition="Exists('$(MSBuildThisFileDirectory)..\build\build-utilities\msbuild\main.targets')" />
	<VisualStudioVersion Condition=" '$(VisualStudioVersion)'=='' ">12.0</VisualStudioVersion>
    <Configuration Condition=" '$(Configuration)'=='' ">Release</Configuration>
    <!-- Location for build output of the project -->
    <OutputRoot Condition=" '$(OutputRoot)'=='' ">$(MSBuildThisFileDirectory)..\BuildOutput\</OutputRoot>
    <!-- Root for the publish output -->
    <PublishFolder Condition=" '$(PublishFolder)'==''">C:\MyTemplates\</PublishFolder>
	<SourceTemplateFolder>C:\Program Files\Common Files\Hexagon\Services\Templates\Geospatial Portal\</SourceTemplateFolder>
	<LanguageFiles Include="$(MSBuildThisFileDirectory)..\lib\language-assemblies-main-zip\application-root\**\*.*" />
	<AdministratorFiles Include="$(SourceTemplateFolder)\AdministratorFiles\**\*.*" />
    <ProjectsToBuild Include="$(MSBuildThisFileDirectory)..\src\Application\Application.csproj">
  <Target Name="BuildProjects">
    <MSBuild Projects="@(ProjectsToBuild)" />
	<Copy SourceFiles="@(LanguageFiles)" DestinationFiles="@(LanguageFiles->'$(PublishFolder)$(MyTemplateName)\Files\%(RecursiveDir)%(Filename)%(Extension)')"/>
	<Copy SourceFiles="@(AdministratorFiles)" DestinationFiles="@(AdministratorFiles->'$(PublishFolder)$(MyTemplateName)\AdministratorFiles\%(RecursiveDir)%(Filename)%(Extension)')"/>
    <Copy SourceFiles="$(SourceTemplateFolder)\application.xml" DestinationFolder="$(PublishFolder)$(MyTemplateName)" />
	<XmlUpdate XmlFileName="$(PublishFolder)$(MyTemplateName)\application.xml"
	<XmlUpdate XmlFileName="$(PublishFolder)$(MyTemplateName)\application.xml"
  <Target Name="AfterWebPublish" AfterTargets="WebPublish">
    <Message Text="Inside AfterWebPublish" Importance="high"/>



For convenience you can create a bat file to launch MSBuild command:

@echo off
set msbuild="C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild"
%msbuild% /p:MyTemplateName=%1 Build.xml

Example usage:

   C:\2015SDK\portal\build\maketemplate.bat Test