dotNet Protector Samples - Deployment projects

Protected Exe with embedded runtime

If dotNet Protector's runtime is embedded in the exe, VS 2005 can't successfully build a setup project with it (it complains about the missing embedded.netmodule).

Ignore the missing PvLogiciels.dotNetProtector.Runtime dependency warning (this assembly is also embedded in your exe).

 

Solution :

Build the vdproj with a dummy netmodule and the remove this netmodule from the built msi.

 

Content of EmbeddedSetupPatch.zip

       embedded.netmodule : the dummy netmodule used by PV Logiciels to compile the dotNet Protector® embedded runtime.

       MsiRemoveEmbeddedModule.exe : a command-line utility to remove the dummy netmodule from the generated msi.

 

 

Executables built by dotNet Protector when using the ‘runtime embedding feature’

Starting with the v2 of .NET, assemblies can run in 64 bit mode on 64 bit platforms.

If your assembly is compiled as ‘x86 cpu’, it will run in a x86(emulated on 64 bits windows) box on each platform. In this case, dotNet Protector will build a single x86 protected exe.

 

If your assembly is compiled as ‘any cpu’, the default for pure-IL projects (C#, VB.NET.), it will be converted to a 64 bits executable at run time on 64 bits windows. In this case, dotNet Protector will build 3 executable, one for each platform : x86, ADM64 and Itanium.

If you don’t have the 64 bits platforms available to test the 64 bits exe, forget them and distribute only the x86 one. If you can test the 64 bits, you can build up to 3 setup projects, one for x86, one for AMD64 and one for Itanium. ( change the deployment project’s ‘TargetPlatform’ property accordingly)

 

Building the vdproj project

This step is the same for each platform.

To successfully build the deployment project, you need to provide a compatible embedded.netmodule. Copy the file from EmbeddedSetupPatch into the same location as your exe embedding dotNet Protector’s runtime.

Build your project. In the following, we suppose the vdproj builds mysetup.msi.

WARNING! If you run your exe with an embedded.netmodule on disk, the framework will load this one instead of the embedded one, and your program will fail. This dummy module should be absent in the distribution folder.

The second step removes embedded.netmodule from the distribution folder by patching the msi database.

Run the command

MsiRemoveEmbeddedModule mysetup.msi

After this step, mysetup.msi won’t install embedded.netmodule

 

Automatic build of the vdproj project

You can automate the build and patch process using a batch file

Suppose

the solution path is ‘C:\My Projects\mysetup.sln’

the dotNet Protector output path is ‘C:\My Projects\MyExe\Protected

EmbeddedSetupPatch has been uncompressed in C:\ EmbeddedSetupPatch

 


 

 

X86 Only

Say the project name is mysetup, its output directory is ‘C:\My Projects\mysetup\Release’

 

The batch file could be

 

@ECHO OFF

COPY /Y “C:\dotNetProtector\EmbeddedSetupPatch\embedded.netmodule” “C:\My Projects\MyExe\Protected”

SETLOCAL

CALL "%VS80COMNTOOLS%\VSVARS32"

"%VSINSTALLDIR%\Common7\IDE\DEVENV" "C:\My Projects\mysetup.sln" /build "Release" /project mysetup

“C: \EmbeddedSetupPatch\ MsiRemoveEmbeddedModule” “C:\My Projects\mysetup\Release\mysetup.msi”

ENDLOCAL

DEL C:\My Projects\MyExe\Protected\embedded.netmodule

 

Multiple Platform

Say the dotNet Protector output path are ‘C:\My Projects\MyExe\x86’,  ‘C:\My Projects\MyExe\AMD64’ and ‘C:\My Projects\MyExe\Itanium’ respectively

 

the x86 project name is mysetupx86, its output directory is ‘C:\My Projects\mysetupx86\Release’,

the AMD64 project name is mysetupx64, its output directory is ‘C:\My Projects\mysetupx64\Release’, and

the Itanium project name is mysetupia64, its output directory is ‘C:\My Projects\mysetupia64\Release’

The batch file could be

 

@ECHO OFF

COPY /Y “C:\dotNetProtector\EmbeddedSetupPatch\embedded.netmodule” “C:\My Projects\MyExe\x86”

COPY /Y “C:\dotNetProtector\EmbeddedSetupPatch\embedded.netmodule” “C:\My Projects\MyExe\AMD64”

COPY /Y “C:\dotNetProtector\EmbeddedSetupPatch\embedded.netmodule” “C:\My Projects\MyExe\Itanium”

SETLOCAL

CALL "%VS80COMNTOOLS%\VSVARS32"

"%VSINSTALLDIR%\Common7\IDE\DEVENV" "C:\My Projects\mysetup.sln" /build "Release" /project mysetupx86

“C: \EmbeddedSetupPatch\ MsiRemoveEmbeddedModule” “C:\My Projects\mysetupx86\Release\mysetupx86.msi”

"%VSINSTALLDIR%\Common7\IDE\DEVENV" "C:\My Projects\mysetup.sln" /build "Release" /project mysetupx64

“C: \EmbeddedSetupPatch\ MsiRemoveEmbeddedModule” “C:\My Projects\mysetupx64\Release\mysetupx64.msi”

"%VSINSTALLDIR%\Common7\IDE\DEVENV" "C:\My Projects\mysetup.sln" /build "Release" /project mysetupia64

“C: \EmbeddedSetupPatch\ MsiRemoveEmbeddedModule” “C:\My Projects\mysetupia64\Release\mysetupia64.msi”

ENDLOCAL

DEL C:\My Projects\MyExe\x86\embedded.netmodule

DEL C:\My Projects\MyExe\AMD64\embedded.netmodule

DEL C:\My Projects\MyExe\Itanium\embedded.netmodule


 


Send comments about this topic to PV Logiciels