SmartAssembly - 6.6
Using the command line mode - SmartAssembly
Instead of using the SmartAssembly user interface to build your project, you can use the command line. This is useful if you want to apply a setting to multiple assemblies, or to make a change to existing settings during your build process, for example.
The console application SmartAssembly.com is stored in the same folder as SmartAssembly.exe. This is usually in %ProgramFiles%\Red Gate\SmartAssembly.
To run SmartAssembly from the command line, the syntax is:
SmartAssembly.com [switch] [projectfile | reportfile] [options]
There are two ways to use the command line:
- Integrating SmartAssembly in your build process, or making changes to multiple SmartAssembly projects.
- Performing regular management tasks
Integrating SmartAssembly in your build process, or making changes to multiple SmartAssembly projects.
To use the command line to integrate SmartAssembly in your build process, or to make changes to multiple SmartAssembly projects:
- Choose either to:
- build an assembly based on existing SmartAssembly project settings
- edit existing SmartAssembly project settings
- create new SmartAssembly project settings
- Set the options for your SmartAssembly project
- Set the options for the assemblies in your project
1. Building, creating, or editing a SmartAssembly project
/build myproject.saproj [options] |
Builds the specified project. The project must have been previously created using the SmartAssembly user interface, or by using the /create switch. The settings in the .saproj file are overridden by the specified project options, if given, but the .saproj file itself is not altered. See the section 'Setting project options' for more information about the available project options. |
/create myproject.saproj options |
Creates a new .saproj file with the specified project options The .saproj file is saved with the new options. The assembly itself is not built. Must be used with the /input and /output switches. See the section 'Setting project options' for more information about the available project options. |
/edit myproject.saproj options |
Replaces the settings in the specified project with the specified project options. The project must have been previously created using the SmartAssembly user interface, or by using the /create switch. The .saproj file is saved with the new options. The assembly itself is not built. See the section 'Setting project options' for more information about the available project options. |
2. Setting project options
You can use the following switches to control how SmartAssembly processes your project.
- If you are using the /build or /edit switch, all of these switches are optional.
If you do not set some of the switches, the settings in your .saproj file are used instead.
- If you are using the /create switch, you must set the /input and /output options. All other switches are optional.
If you do not set some of the switches, the settings in bold are used instead.
Setting the input and output assemblies
/input=newassembly.exe
/output=newoutput.exe
Signing your assembly with a strong name key
/keyfilename=[path\to\file.snk | false]
Adding tamper protection to the assembly
/tamperprotection=[true | false]
Apply tamper protection to the assembly.
Reducing the assembly's unused, allocated memory
/reducemem=[true | false]
Sealing classes that are not inherited
/sealclasses=[true | false]
Preventing Microsoft IL Disassembler from opening your assembly
/preventildasm=[true | false]
Setting the types / methods name mangling level
/typemethodobfuscation=[1 | 2 | 3]
Setting the fields name mangling level
Setting strings encoding
- Use improved protection?
- Compress and encrypt resources?
- Cache the strings for improved performance?
Creating a PDB file
Obfuscating URLs in the PDB file
Setting the application, project and company names for use in error and feature usage reports
Enabling error reporting
- continueonerror = Whether or not your application should try to continue after an error.
- email = When an error report is received, an email is sent to this address. To turn of email notifications, set an empty string.
/errorreportingtemplate=[standard | path\to\template.dll];
continueonerror:[true | false],
email:"example@example.com"
Enabling feature usage reporting
- consent1 = Consent dialog on first run
- consent2 = Consent dialog on second run
- auto = Report without consent dialog
- path\to\template.dll = Use this DLL for the consent dialog
- false = Do not enable feature usage reporting
3. Setting assembly options
Some options are set per assembly.
To set these options, type the /assembly: switch, followed by the name of your assembly, then a semi-colon (;).
Add the assembly options, separated by commas, as in this example:
/assembly="MyAssembly";prune:true,merge:true,embed:true,nameobfuscate:true,
dynamicproxy:true,compressencryptresources:true,controlflowobfuscate:1,
compressassembly:true,encryptassembly:true
prune:[true | false], |
Enable / Disable pruning |
merge:[true | false], |
Disable / Enable dependencies merging (Note that you cannot merge the main assembly.) |
embed:[true | false], |
Disable / Enable dependencies embedding This option is ignored if merge:true. (Note that you cannot embed the main assembly.) |
nameobfuscate:[true | false], |
Enable / Disable types and methods obfuscation and field names obfuscation The obfuscation is applied at the levels specified for the project. |
dynamicproxy:[true | false], |
Enable / Disable the references dynamic proxy |
compressencryptresources:[true | false], |
Enable / Disable resources compression and encryption |
controlflowobfuscate:[False | 0 | 1 | 2 | 3], |
Sets the level of control flow obfuscation to apply to the assembly:
|
compressassembly:[true | false], |
Enable / Disable compression when the assembly is embedded. This option is ignored unless embed:true. |
encryptassembly:[true | false] |
Whether you want to encrypt the assembly when it is embedded. This option is ignored unless embed:true and compressassembly:true |
Example usage
This example:
Takes the existing SmartAssembly project file located at C:\Documents\Visual Studio 2010\Projects\Crasher\Crasher\bin\Release\Crasher.saproj and then overwrites it, replacing the following settings. The Crasher assembly is not rebuilt.
- Sign the assembly with the strong name key located at "./g.snk"
- Enable tamper protection
- Enable the reduction of unused, allocated memory
- Automatically seal classes wherever possible
- Enable MSIL Disassembler protection
- Enable Feature Usage Reporting, showing a consent dialog on the first run
- Use Standard renaming for fields in assemblies that have fields renaming enabled
- Use Unicode unprintable characters and advanced renaming algorithm in assemblies that have Types/Methods Name Mangling enabled
- Enable Strings Encoding with Improved Protection, Compress and Encrypt the Strings and enable the cache
- Enable Automatic Error Reporting without a dialog box, trying to continue when an error occurs
- Generate PBD files for the assembly
- For the purposes of Automated Error Reporting and Feature Usage Reporting, name the application 'Hello World', name the project 'testproj', set the company name to 'Red Gate Software' and set the email address to 'example@example.com'. (This is the email address that will be sent a message whenever a new error report arrives.)
Then, within the assembly called "Crasher":
- Enable Pruning
- Enable Merging
- Embed the assembly into the main assembly (which will have been set in the Crasher.saproj file already)
- Enable Types/Methods Name Mangling and Fields Name Mangling
- Enable Control Flow Obfuscation at the 'Strongest' level
- Enable the Dynamic References Proxy
- Enable Resources Compression and Encryption
Performing regular management tasks
You can also use the following command line switches to perform management tasks related to your SmartAssembly installation.
These switches are used on their own; they are not used with the /create, /build, or /edit switches.
/compactdb |
Compacts the SmartAssembly database (smartassembly\database.mdb). Does not apply to SmartAssembly installations using SQL server. |
/downloadnewreports |
Download new feature usage and error reports. |
/markasreleased myassembly.exe |
(Deprecated) This option was used in SmartAssembly 6.2 and earlier to preserve map files. This is no longer necessary because SmartAssembly 6.5 saves map files permanently. For more information, see About map files. |
/addreport myencryptedreport. (With Professional Edition only) |
When you get an encrypted report file sent to you via email, you can either double-click the file (if it has the correct .saencryptedreport extension) or run this command line option. In both cases, the report is added to the database, as if it had been downloaded from the web-service. |
Was this article helpful?
SmartAssembly
- Using Smartassembly to obfuscate a windows service
- Obfuscation not renaming identically-named methods in different classes
- Serialization exceptions occurring in obfuscated assemblies
- SmartAssembly skipping obfuscation of some classes in your assembly
- SmartAssembly is not merging or embedding all assembly dependencies
- Can I customize the path to the MDB database?
- System.InvalidOperationException when attempting to connect to local SmartAssembly database
- Protecting website code using SmartAssembly
- Visual Studio Deployment Projects including unprotected builds
- SmartAssembly MSBUILD tasks failing because of difference in log4net assembly
- SmartAssembly Error Reporting: This application has submitted too many reports
- The assembly is being merged, but the dependent assembly isn't
- ERR 2002: Server did not recognize the value of HTTP Header SOAPAction
- The error report is not associated with a valid project ID - SmartAssembly
- Application built with an evaluation edition of SmartAssembly
- How end users can change their participation in Feature Usage Reporting
- Log file for SmartAssembly
- Moving SmartAssembly to another computer
- 'Using JET databases is not possible in 64-bit applications' error when using MSBuild or TFS
- SmartAssembly stack trace is invalid when Method Parent Obfuscation is enabled
- Upgrading SmartAssembly version 4.x to version 5
- Upgrading SmartAssembly Standard to Professional
- Problems building WPF applications with SmartAssembly 6.7
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
SmartAssembly
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

Using SmartAssembly for obfuscation