In order to build .EXE for deployment, you need to have a licenses.licx file in your solution. However, if you do, you will need to have an SDK license in order to build the solution. If you remove the licenses.licx, you can build, but you cannot run without an SDK license.
Sometimes you want a VS solution that will use a licenses.licx when you have an SDK license, but build an unlicensed .EXE when you don't. In this case, you need compile the licenses.licx in the solution with a custom build step. Here are the instructions:
- Do a normal build of the .EXE in VS 2005 (with licenses.licx embedded). You will need an SDK license to do this. You will notice this command in the Output tab (in this case, the .exe was called MyProgram.exe)
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\LC.exe /target:MyProgram.exe /complist:licenses.licx /outdir:obj\Debug\ /i:"C:\Program Files\Atalasoft\DotImage 5.0\bin\2.0\Atalasoft.dotImage.dll" /i:"C:\Program Files\Atalasoft\DotImage 5.0\bin\2.0\Atalasoft.dotImage.Lib.dll" /i:"C:\Program Files\Atalasoft\DotImage 5.0\bin\2.0\Atalasoft.Shared.dll" /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.VisualC.dll
This command creates a file called MyProgram.exe.licenses in your obj/Debug directory.
The next command to look at this one that does the compile. Part of what it does is include the MyProgram.exe.licenses file as an embedded resource
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\Atalasoft\DotImage 5.0\bin\2.0\Atalasoft.dotImage.dll" /reference:"C:\Program Files\Atalasoft\DotImage 5.0\bin\2.0\Atalasoft.dotImage.Lib.dll" /reference:"C:\Program Files\Atalasoft\DotImage 5.0\bin\2.0\Atalasoft.Shared.dll" /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /debug+ /debug:full /optimize- /out:obj\Debug\TiffValidator.exe /resource:obj\Debug\MyProgam.exe.licenses /target:exe Program.cs Properties\AssemblyInfo.cs
- What you need to do is have a licenses.licx that lists Atalasoft dlls when you have a license and one that is empty when you don't. There are a lot of ways to do that, and it also depends on whether you need other products there or not. Here is a simple way:
a. Open your project properties, in the Build Events tab, add this to the Pre-build event command line
b. create the file createlicx.bat in your project root, put this inside of it
if "%HAS_ATALA%"=="1" goto HASATALA
echo # > C:\devtfs\TiffValidator\licenses.licx
echo Atalasoft.Imaging.AtalaImage, Atalasoft.dotImage > C:\devtfs\TiffValidator\licenses.licx
This will look for a HAS_ATALA environment variable -- if it is set to 1, then it will create a licenses.licx that tries to embed Atalasoft. If not, it creates one with just a comment in it. You need to set the variable to 1 on computers where you have a licensed SDK -- once you set it, you will need to restart Visual Studio so that it picks up this new variable.
This is not the only way to do this, the basic idea is that your licenses.licx should contain lines to embed Atalasoft licenses when the SDK license is on the machine, and should not when it doesn't. Instead of using an environment variable, you could check to see if the Atalasoft.dotImage.lic file exists. Instead of using echo, you could have two copies of the file under different names and copy the right one to licenses.licx. This is just one example.