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?
on top of the Joe's marvelous solution I ended up changing one value from true to false with regards to the instructions on https://www.preemptive.com/dotfuscator/pro/userguide/en/getting_started_xamarin.html#pctoc-setup to get my android solution to build/run.
At some point I was missing the file PreEmptive.Dotfuscator.Xamarin.targets in the root of project. I already executed the instructions above described by Joe Sewell, but later noticed the missing file.
Error were like this:
Just FYI if anyone else could avoid waste of time.
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 namedDotfuscatorConfig.xml
(or whatever value you supplied for theDotfuscatorXamarinConfigFileName
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
, valueobj\Release\DotfuscatorXamarin\dfin
OutDir
, valueobj\Release\DotfuscatorXamarin\dfout
ReportDir
, valueDotfuscatorReports\Release
Release
with the appropriate directory for the configuration you built in step 2. Note that the directories pointed to byOutDir
andReportDir
won't exist on-disk yet.${configdir}\${InDir}\AssemblyName.dll
, substitutingAssemblyName.dll
for the actual name and extension of the assembly. Repeat for each input assembly.I've been configuring the Dotfuscator Community Edition at Xamarin.Android project according to this user guide. And I also had the following build error (pretty the same as @AxiomaticNexus):
I've fixed this issue using @Joe Sewell's Full Disclosure. I hope PreEmptive Solutions will realese the fixed version asap!!!