Skip to main content
Version: 2023.4

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

$(InputDir)

Directory path of the input assembly

C:\Dev\Project1\bin\Release

$(ProjectDir)

Directory path of the MSBuild project

C:\Dev\Project1

$(SolutionDir)

Directory path of the MSBuild solution

C:\Dev

$(ConfigurationName)

Name of MSBuild project configuration

Release

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)]