Dotfuscator throwing error on Xamarin.Android proj

2019-01-26 00:53发布

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?

4条回答
家丑人穷心不美
2楼-- · 2019-01-26 00:57

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.

    <DotfuscatorXamarinGenerateNewConfigFile>false</DotfuscatorXamarinGenerateNewConfigFile>
查看更多
Bombasti
3楼-- · 2019-01-26 01:04

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:

    Error       The "_DotfuscatorXamarin_DetermineDefaultInputsTask" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object.
   at InlineCode._DotfuscatorXamarin_DetermineD  efaultInputsTask.Execute() in c:\Users\hieta\AppData\Local\Temp\k3a5f2bj.0.cs:line 106
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() WorkSafe.Droid      

Just FYI if anyone else could avoid waste of time.

查看更多
混吃等死
4楼-- · 2019-01-26 01:17

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:

  1. In the targets file, locate the _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.
  2. In Visual Studio, build your project once in a configuration you want to protect (e.g., AnyCPU|Release). It will error, because the new config file doesn't have any input assemblies yet, but by building now we get those assemblies in the right location for configuring Dotfuscator.
  3. Open Dotfuscator's user interface.
    • For Community Edition, from Visual Studio, open the Tools menu and select PreEmptive Protection - Dotfuscator.
    • For Professional Edition, run Dotfuscator Professional Edition from the Start Menu.
  4. In the user interface, File | Open the file created in step 1.
  5. On the Inputs screen, click the "Add Input" button (a green plus-sign in Community Edition, a folder-opening icon in Professional Edition).
  6. Browse to your project directory, then obj\Release\DotfuscatorXamarin\dfin, and then select the assemblies you want to protect.
    • Substitute Release with the appropriate directory for the configuration you built in step 2.
    • You should select assemblies that correspond to projects in your solution, and not select third-party and assemblies that are part of the framework.
  7. Save the config file.
  8. Navigate to the Project Properties editor.
    • In Community Edition, go to the Build Settings screen and select the Project Properties tab.
    • In Professional Edition, go to the Settings tab and select the Settings > Project Properties screen.
  9. Add the following project properties (instructions for Community Edition, and for Professional Edition):
    • Property name InDir, value obj\Release\DotfuscatorXamarin\dfin
    • Property name OutDir, value obj\Release\DotfuscatorXamarin\dfout
    • Property name ReportDir, value DotfuscatorReports\Release
    • Substitute 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.
  10. Save the config file.
  11. Return to the Inputs screen and select an input and click the pencil icon. Edit the path to the assembly from an absolute path to ${configdir}\${InDir}\AssemblyName.dll, substituting AssemblyName.dll for the actual name and extension of the assembly. Repeat for each input assembly.
  12. Save the config file (and commit it to source control).
  13. Rebuild the project in Visual Studio. The build integration will use your config file instead of trying to generate a new one.
查看更多
看我几分像从前
5楼-- · 2019-01-26 01:18

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

    Error       The "_DotfuscatorXamarin_DetermineDefaultInputsTask" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object.
   at InlineCode._DotfuscatorXamarin_DetermineDefaultInputsTask.Execute() in c:\Users\user\AppData\Local\Temp\wqhfhbsk.0.cs:line 106
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() eKey.Droid  C:\VSProjects\dotFuscatorTest\PreEmptive.Dotfuscator.Xamarin.targets    570

I've fixed this issue using @Joe Sewell's Full Disclosure. I hope PreEmptive Solutions will realese the fixed version asap!!!

查看更多
登录 后发表回答