.NET Core 5.0: Obfuscar exited with code 123

1.2k Views Asked by At

My configuration

<?xml version='1.0'?>
<Obfuscator>
    <Var name="InPath" value="$(InPath)" />
    <Var name="OutPath" value="$(InPath)\Obfuscar" />
    <Var name="KeepPublicApi" value="false" />
    <Var name="HidePrivateApi" value="true" />
    <Var name="RenameProperties" value="true" />
    <Var name="RenameEvents" value="true" />
    <Var name="RenameFields" value="true" />
    <Var name="UseUnicodeNames" value="true" />
    <Var name="HideStrings" value="true" />
    <Var name="OptimizeMethods" value="true" />
    <Var name="SuppressIldasm" value="true" />
    <Module file="$(InPath)\*.dll" />
    <Module file="$(InPath)\*.exe" />
</Obfuscator>

My Post Build event

if $(ConfigurationName) == Release “$(Obfuscar)” obfuscar.xml

Build output

2>MYApplication -> D:\MYServer\MYApp\bin\Release\net5.0-windows\MYServer.dll 2>The filename, directory name, or volume label syntax is incorrect. 2>D:\MYServer\MYApp\MYApplication.csproj(23,5): error MSB3073: The command "if Release == Release “C:\Users\VVSCPP.nuget\packages\obfuscar\2.2.31\build..\tools\Obfuscar.Console.exe” obfuscar.xml" exited with code 123. 2>Done building project "MYApplication.csproj" -- FAILED.

1

There are 1 best solutions below

0
On

I have copied the above information from various samples in the net, and seems like many of them made the same mistakes.

  1. $(InPath) <= VS macro doesn't work in XML file. Have to use a valid path

  2. .NET core's EXE cannot, and doesn't need to be obfuscated. Only need to obfuscate DLL

  3. The post build even Release “$(Obfuscar)” which I have copied from the web, had the double quote in UNICODE, must manually typed and change back to ASCII