I followed the steps to integrate Dotfuscator into my Xamarin.Android project as described here, but when it's time to build the project, I'm getting the following error:
The "_DotfuscatorXamarin_DetermineDefaultInputsTask" task failed unexpectedly. 2>\path\to\PreEmptive.Dotfuscator.Xamarin.targets(570,5): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object. 2>\path\to\PreEmptive.Dotfuscator.Xamarin.targets(570,5): error MSB4018: at InlineCode._DotfuscatorXamarin_DetermineDefaultInputsTask.Execute() in \path\to\AppData\Local\Temp\eruovv3u.0.cs:line 106 2>\path\to\PreEmptive.Dotfuscator.Xamarin.targets(570,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 2>\path\to\PreEmptive.Dotfuscator.Xamarin.targets(570,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
I have looked and looked online, but no one seems to be having this issue. I think the problem has something to do with generating the default configuration file on the first build. Any ideas?
UPDATE: This issue has been fixed in newer versions of Dotfuscator. See the detailed instructions for the free Dotfuscator Community and for the commercially-licensed Dotfuscator Professional. The original answer follows below.
Full Disclosure: I am a developer of Dotfuscator at PreEmptive Solutions, and am answering this question in that role.
You're right, the problem is the default config file generation in the targets file (PreEmptive.Dotfuscator.Xamarin.targets
) - sorry about that. Specifically, the build integration is attempting to discover project references, but expects the classic MSBuild project format, not the new minimal one used by .NET Standard.
You can work around this issue as follows:
_DotfuscatorXamarinConfigTemplateLines
property and copy its value (within the CDATA section) to a new file named DotfuscatorConfig.xml
(or whatever value you supplied for the DotfuscatorXamarinConfigFileName
property in your project file) in the same directory as your project file.obj\Release\DotfuscatorXamarin\dfin
, and then select the assemblies you want to protect.
Release
with the appropriate directory for the configuration you built in step 2.InDir
, value obj\Release\DotfuscatorXamarin\dfin
OutDir
, value obj\Release\DotfuscatorXamarin\dfout
ReportDir
, value DotfuscatorReports\Release
Release
with the appropriate directory for the configuration you built in step 2. Note that the directories pointed to by OutDir
and ReportDir
won't exist on-disk yet.${configdir}\${InDir}\AssemblyName.dll
, substituting AssemblyName.dll
for the actual name and extension of the assembly. Repeat for each input assembly.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With