How To: Integrate Code Protection into the Build Process with Post-Build Events
With Microsoft Visual Studio 2005 and later, you can define post-build tasks for your development projects. This functionality allows you to integrate Microsoft SLP Code Protector into your build process.
The following sections provide step-by-step instructions for the integration.
Note: Command-line protection cannot be applied if a generic Permutation is used. You must first create a private Permutation.
To Create an SLP Code Protector Configuration File
- Open SLP Code Protector.
- Click the Project tab, and then click View.
- Add the modules, and select the methods you wish to protect. Define all necessary settings for the methods.
- The settings apply to the entire project, the application, and the methods selected for protection. Settings are displayed in the right portion of the page in the Project view. For more information about selecting the settings, refer to the SLP Code Protector User Guide.
- Click File, and then click Save Project As…
- Enter a file name with a .SLMCfg extension, for example, ProtectionSettings.SLMCfg. Click Save. This creates a configuration file called ProtectionSettings.SLMCfg.
To Protect Code in Debug and Release Versions
- Open SLP Code Protector.
- Click File, and then click SaveAs to add the SLP Code Protector configuration file to the project folder.
- Open the project in Visual Studio. If you want to protect both Debug and Release versions of your builds, you must create two copies of the configuration file. Name one of the files Release.SLMCfg and the other Debug.SLMCfg.
- Change the values for InputDir, OutputDir, and ModuleName to the appropriate directories.
- Save your changes.
To Create A Custom Post-Build Action
- Open the Properties window of your project.
- Open the Build Events tab.
- Add the following post-build event.
"%Programfiles%\Microsoft SLP Code Protector\Microsoft.Licensing.ProtectCmd.exe" "$(ProjectDir)$(ConfigurationName).SLMCfg"
- Build the project. Verify that protection has succeeded by reviewing the results in the Output window.
Compile complete -- 0 errors, 0 warnings
TestBuild -> C:\Users\testuser\Documents\Visual Studio 2005\Projects\TestBuild\TestBuild\bin\Debug\TestBuild.exe
"%Programfiles%\Microsoft SLP Code Protector\Microsoft.Licensing.ProtectCmd.exe" "C:\Users\testuser\Documents\Visual Studio 2005\Projects\TestBuild\TestBuild\Debug.SLMCfg"
Performing code transformation...
Embedding required resources...
Preparing output directory...
Writing protected files to "C:\Users\testuser\Documents\Visual Studio 2005\Projects\TestBuild\TestBuild\bin\Debug.Protected"
Copying miscellaneous files from input directory "C:\Users\testuser\Documents\Visual Studio 2005\Projects\TestBuild\TestBuild\bin\Debug" to output directory "C:\Users\testuser\Documents\Visual Studio 2005\Projects\TestBuild\TestBuild\bin\Debug.Protected"
Writing permutation-specific redistributable files to "C:\Users\testuser\Documents\Visual Studio 2005\Projects\TestBuild\TestBuild\bin\Debug.Protected"
Protection succeeded
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
See Also
How To: Apply Command-Line Application Protection with SLP Code Protector
What do you think about this topic? Send feedback!
|