本文介绍了Dotfuscator 在 Xamarin.Android 项目上抛出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照上述步骤将 Dotfuscator 集成到我的 Xamarin.Android 项目中 here,但是当需要构建项目时,我收到以下错误:

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:

_DotfuscatorXamarin_DetermineDefaultInputsTask"任务意外失败.2>pathoPreEmptive.Dotfuscator.Xamarin.targets(570,5):错误 MSB4018:System.NullReferenceException:未将对象引用设置为对象的实例.2>pathoPreEmptive.Dotfuscator.Xamarin.targets(570,5): error MSB4018: at InlineCode._DotfuscatorXamarin_DetermineDefaultInputsTask.Execute() in pathoAppDataLocalTemperuovv3u.0.cs:line1062>pathoPreEmptive.Dotfuscator.Xamarin.targets(570,5): 错误 MSB4018: 在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()2>pathoPreEmptive.Dotfuscator.Xamarin.targets(570,5): 错误 MSB4018: 在 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:此问题已在较新版本的 Dotfuscator 中修复.请参阅免费的 Dotfuscator 社区的详细说明 和商业许可的 Dotfuscator Professional.原始答案如下.

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.

完全披露:我是 PreEmptive Solutions 的 Dotfuscator 开发人员,正在以该角色回答这个问题.

Full Disclosure: I am a developer of Dotfuscator at PreEmptive Solutions, and am answering this question in that role.

您说得对,问题在于目标文件 (PreEmptive.Dotfuscator.Xamarin.targets) 中的默认配置文件生成 - 对此很抱歉.具体来说,构建集成试图发现项目引用,但期望经典的 MSBuild 项目格式,而不是 .NET Standard 使用的新的最小格式.

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. 在目标文件中,找到 _DotfuscatorXamarinConfigTemplateLines 属性并将其值(在 CDATA 部分内)复制到名为 DotfuscatorConfig.xml(或您提供的任何值)的新文件中项目文件中的 DotfuscatorXamarinConfigFileName 属性)与项目文件位于同一目录中.
  2. 在 Visual Studio 中,以要保护的配置(例如,AnyCPU|Release)构建一次项目.它会出错,因为新的配置文件还没有任何输入程序集,但是通过现在构建,我们将这些程序集放在正确的位置以配置 Dotfuscator.
  3. 打开 Dotfuscator 的用户界面.
    • 对于社区版,从 Visual Studio 打开工具"菜单并选择抢先保护 - Dotfuscator".
    • 对于专业版,请从开始"菜单运行 Dotfuscator 专业版.
  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.
  • Release 替换为您在第 2 步中构建的配置的相应目录.
  • 您应该选择与解决方案中的项目相对应的程序集,而不是选择第三方和属于框架的程序集.
  • 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.
  • 在 Community Edition 中,转到 Build Settings 屏幕并选择 Project Properties 选项卡.
  • 在专业版中,转到设置标签并选择设置>项目属性屏幕.
  • 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.
  • 属性名称InDir,值objReleaseDotfuscatorXamarindfin
  • 属性名称OutDir,值objReleaseDotfuscatorXamarindfout
  • 属性名称ReportDir,值DotfuscatorReportsRelease
  • Release 替换为您在第 2 步中构建的配置的适当目录.请注意,OutDirReportDir 指向的目录获胜'尚不存在于磁盘上.
  • Property name InDir, value objReleaseDotfuscatorXamarindfin
  • Property name OutDir, value objReleaseDotfuscatorXamarindfout
  • Property name ReportDir, value DotfuscatorReportsRelease
  • 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.

这篇关于Dotfuscator 在 Xamarin.Android 项目上抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 11:34