### SmartAssembly Build Output Example Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-readytorun-images-net-core-3 This is an example of the output you might see in the command line after a successful publish, indicating that SmartAssembly has processed your application. Paths are shortened for brevity. ```text Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved. Restore completed in 206.38 ms for C:\[..]\ConsoleApp\ConsoleApp.csproj. ConsoleApp -> C:\[..]\ConsoleApp\bin\Release\netcoreapp3.1\win-x64\ConsoleApp.dll **Executing SmartAssembly from: C:\PROGRA~1\Red Gate\SmartAssembly 7\SmartAssembly.com** **Using project: C:\[..]\ConsoleApp\ConsoleApp.saproj** **SmartAssembly v7.4.0.3402 Personal** **Copyright c Red Gate Software Ltd 2005-2020** **Loading project C:\[..]\ConsoleApp\ConsoleApp.saproj** **Input=C:\[..]\ConsoleApp\bin\Release\netcoreapp3.1\win-x64\ConsoleApp.dll** **Loading...** **Starting...** **Analyzing...** **Preparing...** **Creating assembly...** **Copying additional files...** **OK** ConsoleApp -> C:\[..]\ConsoleApp\bin\Release\netcoreapp3.1\win-x64\publish\ ``` -------------------------------- ### Install SmartAssembly Installer using NuGet Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-azure-pipelines This command installs the SmartAssembly.Installer package. Ensure this task is placed at the beginning of your agent job. ```powershell 1. install RedGate.SmartAssembly.Installer /OutputDirectory $(System.DefaultWorkingDirectory) ``` -------------------------------- ### Download SmartAssembly Installer Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-azure-pipelines This task downloads the RedGate.SmartAssembly.Installer package from NuGet. ```yaml - task: NuGetCommand@2 displayName: 'SmartAssembly download' inputs: command: 'custom' arguments: 'install RedGate.SmartAssembly.Installer /OutputDirectory $(System.DefaultWorkingDirectory)' ``` -------------------------------- ### Install SmartAssembly Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-azure-pipelines This task installs SmartAssembly on a build agent using the downloaded installer and a provided license key. Ensure the license key is stored as a secret variable named SA_KEY. ```yaml - task: PowerShell@2 displayName: 'SmartAssembly installation' inputs: targetType: 'inline' script: | $saExtractPath = "$(System.DefaultWorkingDirectory)\RedGate.SmartAssembly.Installer*\tools\" $saInstallLocation = "$(System.DefaultWorkingDirectory)\tools\SA\" "##[debug] Installing SmartAssembly..." $msiPath = (Get-ChildItem "$saExtractPath\SmartAssembly_*_x64.msi").FullName "Installing SmartAssembly from $msiPath into $saInstallLocation" $p = Start-Process -FilePath msiexec -Args "/qn /i `"$msiPath`" INSTALLDIR=`"$saInstallLocation`" RG_LICENSE=`"$(SA_KEY)`" RG_WARNING=`"Ignore`" REBOOT=`"ReallySuppress`" RG_I=`"Red Gate Software Ltd.`"" -Wait -Verbose -PassThru if ($p.ExitCode -ne 0) { throw "SmartAssembly installation failed. Installer exited with code: $($p.ExitCode)" } ``` -------------------------------- ### Example: Deactivate SQL Compare via Command Line Source: https://documentation.red-gate.com/sa/getting-started/licensing/deactivating An example of using the command-line deactivation for the SQL Compare product. ```bash 1. sqlcompare /deactivateSerial ``` -------------------------------- ### Install SmartAssembly using PowerShell Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-azure-pipelines This PowerShell script installs SmartAssembly, using the license key stored as a secret variable. It locates the MSI installer and configures the installation directory and license. ```powershell $saExtractPath = "$(System.DefaultWorkingDirectory)\RedGate.SmartAssembly.Installer*\tools\" $saInstallLocation = "$(System.DefaultWorkingDirectory)\Tools\SA\" "##[debug] Installing SmartAssembly..." $msiPath = (Get-ChildItem "$saExtractPath\SmartAssembly_*_x64.msi").FullName "Installing SmartAssembly from $msiPath into $saInstallLocation" $p = Start-Process -FilePath msiexec -Args "/qn /i `"$msiPath`" INSTALLDIR=`"$saInstallLocation`" RG_LICENSE=`"$(SA_KEY)`" RG_WARNING=`"Ignore`" REBOOT=`"ReallySuppress`" RG_I=`"Red Gate Software Ltd.`"" -Wait -Verbose -PassThru if ($p.ExitCode -ne 0) { throw "SmartAssembly installation failed. Installer exited with code: $($p.ExitCode)" } ``` -------------------------------- ### Project File with Multiple Target Frameworks Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-msbuild/process-a-project-targeting-multiple-frameworks Example of a .csproj file defining multiple target frameworks using the `` property. ```xml netcoreapp3.1;net472;netstandard2.1 ``` -------------------------------- ### Example Assembly Options Configuration Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode This snippet demonstrates setting multiple assembly options including pruning, merging, embedding, name obfuscation, dynamic proxy, resource compression/encryption, control flow obfuscation, assembly compression/encryption, and signing with a key file and password. ```command-line 1. /assembly="MyAssembly";prune:true,merge:true,embed:true,nameobfuscate:true,dynamicproxy:true,compressencryptresources:true,controlflowobfuscate:1,compressassembly:true,encryptassembly:true,keyfilename:file.pfx,keypassword:"p@ssword" ``` -------------------------------- ### DLL2 Code Before Embedding Source: https://documentation.red-gate.com/sa8/obfuscating-your-code-with-smartassembly/embedding-dependencies Example code for DLL2 before dependency embedding. ```csharp 1. internal class InvalidDocumentContentsException : Exception 2. internal class LinkGrep ``` -------------------------------- ### MainExe Code Before Embedding Source: https://documentation.red-gate.com/sa8/obfuscating-your-code-with-smartassembly/embedding-dependencies Example code for MainExe before dependency embedding. ```csharp 1. public sealed class DiscoveryClientResult 2. internal struct CallId ``` -------------------------------- ### Visual Basic .NET Example: Using Custom Attributes Source: https://documentation.red-gate.com/sa8/using-custom-attributes This Visual Basic .NET code shows how to apply custom attributes like ReportException and DoNotPrune to methods and types for SmartAssembly. ```vbnet Imports RedGate.SmartAssembly.Attributes Namespace MyNamespace Public Class MyClass Public Sub MyMethod() ' Method code End Sub End Class Public Class AnotherClass ' Class code End Class End Namespace ``` -------------------------------- ### C# Example: Using Custom Attributes Source: https://documentation.red-gate.com/sa8/using-custom-attributes This C# code demonstrates how to apply custom attributes like ReportException and DoNotPrune to methods and types to control SmartAssembly's behavior. ```csharp using RedGate.SmartAssembly.Attributes; namespace MyNamespace { [ReportException] public class MyClass { public void MyMethod() { // Method code } } [DoNotPrune] public class AnotherClass { // Class code } } ``` -------------------------------- ### MainExe Code After Embedding Source: https://documentation.red-gate.com/sa8/obfuscating-your-code-with-smartassembly/embedding-dependencies Example code for MainExe after embedding DLL1 and DLL2 as resources. ```csharp 1. public sealed class DiscoveryClientResult 2. internal struct CallId 3. 4. Resource1 (containing compressed/encoded contents of DLL1) 5. Resource2 (containing compressed/encoded contents of DLL2) ``` -------------------------------- ### DLL1 Code Before Embedding Source: https://documentation.red-gate.com/sa8/obfuscating-your-code-with-smartassembly/embedding-dependencies Example code for DLL1 before dependency embedding. ```csharp 1. internal class InvalidDocumentContentsException : Exception 2. public sealed class DiscoveryDocument ``` -------------------------------- ### Create SmartAssembly.settings File with Database Connection Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-azure-pipelines/configure-database-connection-on-azure-pipelines This PowerShell task configures the database connection string for SmartAssembly by creating a SmartAssembly.settings file. It uses pipeline variables for secure password handling. Ensure this task is added after the SmartAssembly installation task. ```yaml - task: PowerShell@2 displayName: 'SmartAssembly.settings' inputs: targetType: 'inline' script: | ######################## $saDbHost = "YOUR_DATABASE_HOST"; # replace with host of your database server $saDbUser = "YOUR_DATABASE_USER"; # replace with your database username $saDbName = "SmartAssembly"; # database will be created if it doesn't exist ######################## $saDbPass = "$(SA_DB_PASSWORD)"; "" | Out-File -FilePath "$($env:ProgramData)\Red Gate\SmartAssembly 8\SmartAssembly.settings" -Verbose ``` -------------------------------- ### Compact Database Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Compacts the SmartAssembly database. This command is not applicable to installations using SQL Server. ```command-line _/compactdb_ ``` -------------------------------- ### Create New SmartAssembly Project from Command Line Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Creates a new .saproj file with specified project options. This command requires /input and /output switches and does not build the assembly. The .saproj file is saved with the new options. ```command-line _/create myproject.saproj options_| ``` -------------------------------- ### Build SmartAssembly Project from Command Line Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Builds a specified SmartAssembly project using existing settings. Project settings in the .saproj file can be overridden by command-line options without altering the file itself. ```command-line _/build myproject.saproj [options]_ ``` -------------------------------- ### Publishing a .NET Core Application Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-readytorun-images-net-core-3 Command to publish a .NET Core application as a self-contained, 64-bit Windows application. Providing a runtime identifier is crucial for using ReadyToRun. ```bash dotnet publish .\ConsoleApp.csproj -c Release -r win-x64 ``` -------------------------------- ### Project File with SmartAssembly NuGet Package Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-readytorun-images-net-core-3 This XML snippet shows the necessary additions to your .csproj file to include the RedGate.SmartAssembly.MSBuild NuGet package. Ensure the `PublishReadyToRun` property is set to `true` for ReadyToRun images. ```xml Exe netcoreapp3.1 true all runtime; build; native; contentfiles; analyzers; buildtransitive ``` -------------------------------- ### Build with SQLite Database Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Builds a project using a SQLite database. Specify the database type and path. ```command-line SmartAssembly.com /build ConsoleApp.saproj /dbType=SQLite /dbPath=C:\path\to\sqlite-database-file.db ``` -------------------------------- ### Deactivate SmartAssembly via Command Line Source: https://documentation.red-gate.com/sa/getting-started/licensing/deactivating Specific command to deactivate SmartAssembly using its command-line interface. Ensure you navigate to the correct installation directory. ```bash 1. SmartAssembly.com /deactivateSerial ``` -------------------------------- ### DLL Entry Point for Error Reporting Source: https://documentation.red-gate.com/sa/setting-up-error-reporting/error-reporting-and-dlls This method involves modifying your DLL to include an entry point, similar to an executable, to allow SmartAssembly to receive exceptions. It's suitable for add-ins and some web services. Ensure the static constructor calls `Program.Main()` to initialize SmartAssembly. ```csharp class Program { static void Main() { //empty } }   class MyPlugin : IPlugin { static MyPlugin() { //ensure that sa initialization is executed Program.Main(); }   //your code here... } ``` -------------------------------- ### C# Class with ForceObfuscate Attribute Source: https://documentation.red-gate.com/sa/using-custom-attributes Illustrates using the ForceObfuscate attribute to ensure a class and its methods are obfuscated, including an example of using a hash for method names. ```csharp 1. [ForceObfuscate] 2. public class ThisClassShouldBeObfuscated 3. { 4. public ThisClassShouldBeObfuscated() { /* obfuscated constructor */ } 5. 6. [ForceObfuscate(true)] 7. public void ThisMethodShouldBeObfuscatedUsingHash(string thisParameterShouldBeObfuscatedUsingHash) { } 8. } ``` -------------------------------- ### Describe ApiAssembly with Command Line Parameters Source: https://documentation.red-gate.com/sa/obfuscating-your-code-with-smartassembly/merging-dependencies/merging-assemblies-others-depend-on Describe an assembly named 'ApiAssembly' using command-line parameters, including options for pruning, merging, embedding, and specifying key file and password. ```bash /assembly="ApiAssembly";prune:true,merge:true,embed:true,keyfilename:PathToFile,keypassword:"KeyPassword" ``` -------------------------------- ### Code Before Embedding Dependencies Source: https://documentation.red-gate.com/sa/obfuscating-your-code-with-smartassembly/embedding-dependencies Illustrates the structure of DLL1, DLL2, and MainExe before embedding dependencies. ```csharp 1. internal class InvalidDocumentContentsException : Exception 2. public sealed class DiscoveryDocument ``` ```csharp 1. internal class InvalidDocumentContentsException : Exception 2. internal class LinkGrep ``` ```csharp 1. public sealed class DiscoveryClientResult 2. internal struct CallId ``` -------------------------------- ### Execute SmartAssembly Manually with PowerShell Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-azure-pipelines This PowerShell script can be added as a task in Azure Pipelines to manually run SmartAssembly. Ensure the paths to the SmartAssembly installation and your .saproj file are correct. ```powershell $saInstallLocation = "$(System.DefaultWorkingDirectory)\Tools\SA\" $saComPath = "$saInstallLocation\SmartAssembly.com" "##[debug] Executing SmartAssembly..." & $saComPath /build "$(Build.SourcesDirectory)\AppsToObfuscate\Net472ConsoleApp\Net472ConsoleApp.saproj" # replace with path to your .saproj file ``` -------------------------------- ### Example of String Encoding Effect Source: https://documentation.red-gate.com/sa8/obfuscating-your-code-with-smartassembly/encoding-strings Illustrates the transformation of readable strings into an encoded format after applying SmartAssembly's string encoding. This shows the 'before' and 'after' states of sensitive strings. ```text "Fred.gate@hotmail.com" "p@ssw0rd1" "licensingUrl=http://licensing.red-gate.com/licensingactivation.asmx" ``` ```text "FNRFk1TTJZM016VTPQ==.bmV1dSBzcGVjaWZpZWQ9sbGVjdGlvbi4=L" ``` -------------------------------- ### .NET Core Project File with ReadyToRun Enabled Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-readytorun-images-net-core-3 This project file includes the 'PublishReadyToRun' property set to 'true', enabling the ReadyToRun compilation for the .NET Core application. ```xml Exe netcoreapp3.1 true ``` -------------------------------- ### Custom Usage Reporter for .NET Core Source: https://documentation.red-gate.com/sa8/reporting-feature-usage/how-end-users-can-change-their-participation-in-feature-usage-reporting Example of inheriting from UsageReporter and overriding methods for custom feature usage reporting in .NET Core applications. Reports are sent only when CanReportUsage returns True. ```csharp public class CustomUsageReporter : SmartUsageCore.UsageReporter { public override bool CanReportUsage() { // Return true if the user has opted-in to reporting return base.CanReportUsage(); } public override void ReportUsage(string featureName) { if (CanReportUsage()) { base.ReportUsage(featureName); } } } ``` -------------------------------- ### Precompile ASP.NET Website Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-an-asp-net-website Use the `aspnet_compiler.exe` utility to precompile your ASP.NET website. This command creates a precompiled version of your website in a specified output directory. ```bash 1. aspnet_compiler -v "/" -d -p "c:\mywebsite" "c:\mynewwebsite" ``` -------------------------------- ### Forcing Obfuscation with Custom Attributes in VB.NET Source: https://documentation.red-gate.com/sa8/using-custom-attributes This example demonstrates using the ForceObfuscate attribute in Visual Basic .NET to explicitly control obfuscation for a class and its members. It shows how to force obfuscation for the entire class and specific methods, including parameters. ```vb.net 1. 2. Public Class ThisClassShouldBeObfuscated 3. Public Sub New() 4. ' obfuscated constructor 5. End Sub 6. 7. 8. Public Sub ThisMethodShouldBeObfuscatedUsingHash(ByVal thisParameterShouldBeObfuscatedUsingHash As String) 9. End Sub 10. End Class ``` -------------------------------- ### Migrate MDB to SQL Server using Command Line Source: https://documentation.red-gate.com/sa/upgrading/migrating-your-smartassembly-database/migrating-from-mdb-to-sql-server Use this command to migrate your SmartAssembly database from an MDB file to a SQL Server instance. Ensure you replace the placeholder paths with your actual file and instance details. ```command-line C:\Program Files\Red Gate\SmartAssembly 8\MigrateFromMDB\MigrateDataFromMDB.exe "C:\ProgramData\Red Gate\SmartAssembly\database.mdb" ".\SQLEXPRESS" ``` -------------------------------- ### Copy Website Files Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-an-asp-net-website Use the `xcopy` command to copy all non-DLL files from the original compiled website to the SmartAssembly-protected output directory. This ensures all necessary assets are transferred. ```batch 1. xcopy c:\mynewwebsite c:\mynewSAwebsite /E /EXCLUDE:\bin\ ``` -------------------------------- ### Sign Assembly with Strong Name Key Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Specify the strong name key file for signing your assembly. Use 'false' to disable signing. ```bash /keyfilename=[_path\to\file.snk | path\to\file.pfx | **false**] ``` -------------------------------- ### Specify Files to Copy via Command Line Source: https://documentation.red-gate.com/sa/building-your-assembly/copying-files-and-dependencies-after-build Use the /copyFiles argument with SmartAssembly.com to add files to be copied after the build. Paths are relative to the project file. ```command-line SmartAssembly.com /edit MyApplication.saproj "/copyFiles=./bin/Debug/sample.config;./bin/Debug/some_configuration.json" ``` -------------------------------- ### Deactivate Product via Command Line Source: https://documentation.red-gate.com/sa/getting-started/licensing/deactivating Use this command to initiate the deactivation process for a Redgate product from the command line. Replace with the actual executable name of the product. ```bash 1. /deactivateSerial ``` -------------------------------- ### Basic .NET Core Project File Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-readytorun-images-net-core-3 This is a standard .NET Core project file for a console application. It defines the output type and target framework. ```xml Exe netcoreapp3.1 ``` -------------------------------- ### C# Attributes for Obfuscation and Control Source: https://documentation.red-gate.com/sa8/using-custom-attributes Demonstrates the application of various attributes to classes, methods, properties, and parameters to control obfuscation, pruning, and exception reporting. ```csharp 1. [DoNotSealType()] 2. public class MyClass 3. { 4. [DoNotPrune()] 5. [DoNotObfuscate()] 6. public void CalledOnlyByReflection() 7. { 8. } 9. [DoNotPrune()] 10. public string MyPropertyCalledByReflection 11. { 12. get 13. { 14. return "hello world"; 15. } 16. } 17. public void DoSomething([DoNotPrune()] string myString) 18. { 19. } 20. [ReportException()] 21. [ObfuscateControlFlow()] 22. public void DoSomethingDangerous() 23. { 24. } 25. public MyClass() 26. { 27. } 28. [DoNotPrune()] 29. public MyClass(string[] args) 30. { 31. //Called only by Reflection 32. } 33. } 34. 35. [DoNotPruneType()] 36. [DoNotObfuscateType()] 37. public class OtherClass 38. { 39. } ``` -------------------------------- ### SmartAssembly Project File Configuration for Copying Dependencies Source: https://documentation.red-gate.com/sa/building-your-assembly/copying-files-and-dependencies-after-build This XML snippet shows the SmartAssembly project file structure with the element added within the node, indicating that dependencies should be copied. ```xml ./bin/Debug/MyApplication.exe ... ... ``` -------------------------------- ### Copy Dependencies After Build Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Set the option to automatically copy dependencies, their configurations, and satellite assemblies to the output folder after the build is complete. ```bash _/copyDependencies=[true |**false**]_ ``` -------------------------------- ### Basic MSBuild Project Structure Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-clickonce-and-msi This XML snippet shows a basic structure of an MSBuild project file before modifications. ```xml ... ... ... ``` -------------------------------- ### Set Strong Name Key Password Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Provide the password for a PFX key file. Alternatively, use /keypasswordenv to read the password from an environment variable. ```bash /keypassword=[_ _keypassword_ | **false**] ``` -------------------------------- ### Edit Existing SmartAssembly Project from Command Line Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Replaces the settings in an existing SmartAssembly project file with specified project options. The .saproj file is updated, but the assembly is not built. This command is used for modifying existing project configurations. ```command-line _/edit myproject.saproj options_| ``` -------------------------------- ### Project File XML for Copying Files Source: https://documentation.red-gate.com/sa/building-your-assembly/copying-files-and-dependencies-after-build Manually add the and sections to your SmartAssembly project file to specify files for copying. Paths are relative to the project file. ```xml ./bin/Debug/MyApplication.exe ./bin/Debug/sample.config ./bin/Debug/some_configuration.json ... ... ``` -------------------------------- ### Enable Tamper Protection Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Apply tamper protection to the assembly. This setting is ignored if /keyfilename is set to false. ```bash /tamperprotection=[true | **false**] ``` -------------------------------- ### Configure JIT Optimization Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Control Just-In-Time (JIT) optimization for error reporting. Enabling it can improve performance but may lead to inaccurate line numbers in error reports. ```bash _/jitoptimization=[true_ _|_ **false** _]_ ``` -------------------------------- ### Configure SmartAssembly Project Path for Each Target Framework Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-msbuild/process-a-project-targeting-multiple-frameworks Adds a target to the .csproj file to dynamically set the SmartAssembly project file path based on the current target framework. This ensures the correct SmartAssembly project is used for each build. ```xml ... $(MSBuildProjectDirectory)\$(AssemblyName)_$(TargetFramework).saproj ``` -------------------------------- ### Configure Error Reporting Options Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Set project options for error reporting, including whether to continue on error and the email address for notifications. Use a custom template DLL for error reports. ```bash _/errorreportingtemplate=[standard |_ path\to\template.dll _];_ _continueonerror:[_ **true** _| false],_ _email:"example@example.com"_ ``` -------------------------------- ### Import SmartAssembly Targets into Project Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-clickonce-and-msi This line should be added to your C# or VB.NET project file to include the custom SmartAssembly MSBuild targets. ```xml ``` -------------------------------- ### Copy Additional Files After Build Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Specify additional files to be copied from the input directory to the output directory after the build. Paths can be absolute or relative to the .saproj file, and files must be within the input assembly's directory. ```bash _/copyFiles=path\to\file1.txt;path\to\file2.txt;..._ ``` -------------------------------- ### Specify Input and Output Assemblies Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Use these switches to override the input and output assembly paths specified in the .saproj file. They are mandatory when using the /create switch. ```bash /input=newassembly.exe /output=newoutput.exe ``` -------------------------------- ### C# Force Obfuscation with Hash Option Source: https://documentation.red-gate.com/sa8/using-custom-attributes Illustrates how to use the ForceObfuscate attribute to ensure a class and its methods are obfuscated. Shows the usage of the 'true' parameter for hash-based naming. ```csharp 1. [ForceObfuscate] 2. public class ThisClassShouldBeObfuscated 3. { 4. public ThisClassShouldBeObfuscated() { /* obfuscated constructor */ } 5. 6. [ForceObfuscate(true)] 7. public void ThisMethodShouldBeObfuscatedUsingHash(string thisParameterShouldBeObfuscatedUsingHash) { } ``` -------------------------------- ### Create PDB File Source: https://documentation.red-gate.com/sa/building-your-assembly/using-the-command-line-mode Create a PDB file in either Windows or Portable format. Set to 'false' to disable PDB file creation. ```bash /makepdb=[true | **false** | portable | windows] ``` -------------------------------- ### Execute SmartAssembly Manually Source: https://documentation.red-gate.com/sa/building-your-assembly/using-smartassembly-with-azure-pipelines This optional task allows manual execution of SmartAssembly using its command-line interface. Provide the path to your .saproj file. ```yaml - task: PowerShell@2 displayName: 'SmartAssembly execution' inputs: targetType: 'inline' script: | $saInstallLocation = "$(System.DefaultWorkingDirectory)\Tools\SA\" $saComPath = "$saInstallLocation\SmartAssembly.com" "##[debug] Executing SmartAssembly..." & $saComPath /build "$(Build.SourcesDirectory)\AppsToObfuscate\Net472ConsoleApp\Net472ConsoleApp.saproj" # replace with path to your .saproj file ```