SQL Comparison SDK
Latest version: 10.0
Knowledge Base
Licensing automated builds with NAnt
Category: Licensing & activation
Date: 20 Sep 2012
Product: SQL Comparison SDK
Microsoft Visual Studio can licence SQL Comparison SDK assemblies automatically. This can also be done without the need to have Visual Studio installed, for instance on a server that automates software builds using the NAnt automated build tool.
Before you start, ensure that any prerequisites are installed. In addition to the .NET Framework, the .NET Framework Software Development Kit (SDK) must also be installed to provide licensing functionality. This is a free download from Microsoft (http://www.microsoft.com/en-us/download/details.aspx?id=15354). Finally, install SQL Comparison SDK, which will provide the .NET assemblies necessary to create a licence available to the build server.
First, a licence needs to be created on the server. Because a form is presented requesting the SQL Comparison SDK serial number, this needs to be done manually, before any builds are configured.
· Open a command prompt and change to the SDK folder (cd C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin)
· Notepad licence.txt
· Enter these contents into licence.txt:
· RedGate.SQLCompare.Engine.Database, RedGate.SQLCompare.Engine<return>
(Note that if you were also referencing Data Compare's engine, you would mention it on the next line)
· Save the file and exit.
· Run the licence compiler:
lc.exe /target:"MyApp.exe" /complist:"licence.txt" /i:"c:\program files (x86)\Red Gate\SQL Comparison SDK 10\Assemblies\SQL Compare\RedGate.SQLCompare.Engine.dll"
At this point, you can enter your SQL Comparison SDK serial number from your Red Gate invoice, and a SQL_Toolkit_v_x.lic file will be created in the profile for all users of the computer. Once this file is present, you should never need to enter the serial number again, and automated builds of any SQL Toolkit project can be licensed automatically by NAnt.
The next step is to configure your build. Following the instructions in the SQL Comparison SDK documentation, create a licenses.licx file in your SQL Toolkit project and check it into your source control system. When your source control provider checks out the source code again, this file will be present in your build folder so that the NAnt licensing task can process it.
Now add a license task to your Nant build script, specifying the location to licenses.licx in your build folder and the location of the Red Gate assembly references required:
<target name="licence">
<license input="${build.dir}MyProject\licenses.licx" target="MyProject.exe" output="${build.dir}MyProject\obj\MyProject.exe.licenses">
<assemblies>
<include name="${DataCompare.path}RedGate.SQLCompare.Engine.dll" />
<include name="${DataCompare.path}RedGate.SQLDataCompare.Engine.dll" />
</assemblies>
</license>
</target>
This action will create a file called MyProject.exe.licenses in the obj subfolder of your build folder. The final step is to link the .licenses file into the resources of your output assembly, however, you cannot include the .licenses file in the references section of the <vbc> or <csc> task, because this resource is already compiled and the <resources> section is meant for resources that have not yet been compiled using resgen.exe.
For this reason, an <arg> section is needed inside your <csc> or <vbc> task in order to force the compiler into including the .licences resource in the compiled assembly:
<arg line="/res:${build.dir}\MyProject\obj\MyProject.exe.licenses" />
Here is an example Nant build script for a Visual Basic project build with the necessary Toolkit licensing in place.
<?xml version="1.0"?>
<project name="Toolkit Licensing Nunit Test" default="build">
<property name="build.dir" value="c:\NantBuilds\MyProject\" />
<property name="DataCompare.path" value="c:\program files\red gate\sql data compare 6\" />
<target name="licence">
<license input="${build.dir}MyProject\licenses.licx" target="MyProject.exe" output="${build.dir}MyProject\obj\MyProject.exe.licenses">
<assemblies>
<include name="${DataCompare.path}RedGate.SQLCompare.Engine.dll" />
<include name="${DataCompare.path}RedGate.SQLDataCompare.Engine.dll" />
</assemblies>
</license>
</target>
<target name="build">
<vbc target="winexe"
output="${build.dir}MyProject\bin\Debug\MyProject.exe"
debug="true"
main="MyProject.Form1"
optioncompare="text"
optionexplicit="true"
optionstrict="true"
rootnamespace="MyProject"
removeintchecks="true"
verbose="true">
<sources>
<include name="${build.dir}MyProject\*.vb" />
</sources>
<arg line="/res:${build.dir}\MyProject\obj\MyProject.exe.licenses" />
<resources dynamicprefix="false" basedir="${build.dir}MyProject\obj" prefix="MyProject">
<include name="${build.dir}MyProject\*.resx"/>
</resources>
<imports>
<import namespace="RedGate.SQLCompare.Engine" />
<import namespace="RedGate.SQL.Shared" />
<import namespace="RedGate.SQLDataCompare.Engine" />
<import namespace="System.Threading" />
<import namespace="System.Windows.Forms" />
<import namespace="Microsoft.VisualBasic" />
<import namespace="System.Collections" />
<import namespace="System.Diagnostics" />
<import namespace="System.Drawing" />
</imports>
<references>
<include name="${DataCompare.path}RedGate.SQLCompare.Engine.dll" />
<include name="${DataCompare.path}RedGate.SQLDataCompare.Engine.dll" />
<include name="${DataCompare.path}RedGate.SQL.Shared.dll" />
<include name="Microsoft.VisualBasic.dll" />
<include name="System.dll" />
<include name="System.Data.dll" />
<include name="System.Deployment.dll" />
<include name="System.Drawing.dll" />
<include name="System.Windows.Forms.dll" />
<include name="System.Xml.dll" />
</references>
</vbc>
</target>
</project>
Document ID: KB200801000220 Keywords: SQL,Toolkit,Licence,NAnt,automated,build
Was this article helpful?
SQL Comparison SDK
- Licenses.licx is not a valid Win32 application
- Application licensing invalidated by renaming assembly
- Excluding a table from a data comparison
- Manually licensing Red Gate assemblies
- RedGate.Licensing.Helper.dll is attempting managed execution inside OS Loader lock
- Troubleshooting SQL Comparison SDK licensing
- SQL Compare synchronization error 'Full-Text Search is not installed'
- Using SQL Data Compare mappings in projects using the API
- Licensing automated builds with NAnt
- Licensing ASP .NET applications
- Running SQL code inside SQL Comparison SDK applications
- Creating an HTML report of schema differences in C#
- Creating a synchronization script without batch markers
- Creating an HTML report of schema differences in Visual Basic .NET
- SQL Toolkit has become SQL Comparison SDK
- SQL Comparison SDK column mapping
- Executing your own SQL queries together with SDK synchronization
- Error 1603 occurring during installation
- Licensing SDK applications in Visual Studio 2010
all SQL products
- Compatibility of Red Gate tools in 64-bit environments
- Application has encountered an error and needs to close
- Error message after installing SQL Toolbelt - The description for Event ID ( 1 ) in Source ( nview_info ) cannot be found.
- Changing the temporary directory used by the installer
- Toolbelt Installer "hanging" while "scanning volumes"
- Login failing with "trusted SQL Server connection" error when using RunAs
all products
- Some Red Gate products identified as containing a trojan by Anti-Virus software
- Activation may fail with Unknown Error -1
- Product uses web help although a CHM file is available locally
- Argument exception resulting from missing environment variable
- Check for updates may fail when used through proxies
- 'Unidentified Publisher' error when repairing or uninstalling
- Licensing activates product as standard edition
- Moving Red Gate software products to another machine
- Red Gate tools log locations
- The application UI opening slowly when there is no internet access
SQL Comparison SDK
all SQL products
all products
- Red Gate product acknowledgements
- Activating your products
- Activating your products
- Red Gate bundle history
- Check for updates
- Troubleshooting Check for Updates errors
- Current versions
- Deactivating your products
- Installing Red Gate products from the .msi file
- Requesting additional activations
- Serial numbers for bundles
- Reactivating using a different serial number
- Extending your trial
- Finding your serial numbers
- Moving a serial number from one computer to another
- No response received for manual activation
- Licensing and activation resources
- Licensing and activation resources
- Troubleshooting licensing and activation errors
- Licensing and activation FAQs
- Red Gate tools log file locations
- Download old versions of products
- Download product prerequisites & utilities
- Support & upgrades
- Upgrading your software
- Upgrading FAQs

Licensing and distribution