7.3. Script Variables
Eazfuscator.NET provides support for script variables that can be used to configure the following features:
The list of available script variables is presented in the table below.
Table 7.1. The list of available script variables
Variable | Description | Example value |
---|---|---|
| Directory path of the input assembly |
|
| Directory path of the MSBuild project |
|
| Directory path of the MSBuild solution |
|
| Name of MSBuild project configuration |
|
Environment variables can be referenced using $(env:VARIABLE)
syntax, where VARIABLE
is the name of an environment variable to reference.
Referencing a NuGet package path
Sometimes, you may need to reference a path to a NuGet package. Say, you want to embed a platform-specific assembly from that package. SDK-style projects provide a way to achieve this. First, in the project file, you must set a GeneratePathProperty
of the corresponding PackageReference
to true. Here is an example:
<PackageReference Include="Contoso.Engine" Version="1.0.0" GeneratePathProperty="true"/>
This causes an MSBuild property PkgContoso_Engine
to hold the path of the NuGet package directory. The property's name is composed as Pkg{PackageId}
with the dots replaced by underscores.
You can reference Pkg
build properties in obfuscation directives the same way as script variables — for instance, the Contoso.Engine
path can be referenced as $(PkgContoso_Engine)
:
using System.Reflection;
[assembly: Obfuscation(Feature = "embed $(PkgContoso_Engine)\\runtimes\\win\\lib\\net6.0\\Contoso.Engine.dll", Exclude = false)]