Xamarin.Android项目上的Dotfuscator抛出错误 [英] Dotfuscator throwing error on Xamarin.Android project
问题描述
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> \ path \ to \ PreEmptive.Dotfuscator.Xamarin.targets(570,5):错误MSB4018:System.NullReferenceException:对象引用未设置为对象的实例. 2> \ path \ to \ PreEmptive.Dotfuscator.Xamarin.targets(570,5):错误MSB4018:at InlineCode._DotfuscatorXamarin_DetermineDefaultInputsTask.Execute()在\ path \ to \ AppData \ Local \ Temp \ eruovv3u.0.cs:line中106 2> \ path \ to \ PreEmptive.Dotfuscator.Xamarin.targets(570,5):错误MSB4018:位于Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 2> \ path \ to \ PreEmptive.Dotfuscator.Xamarin.targets(570,5):错误MSB4018:位于Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
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?
推荐答案
更新:此问题已在较新版本的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:
- 在目标文件中,找到
_DotfuscatorXamarinConfigTemplateLines
属性,然后将其值(在CDATA部分中)复制到名为DotfuscatorConfig.xml
的新文件中(或为项目文件中的DotfuscatorXamarinConfigFileName
属性提供的任何值).与您的项目文件相同的目录. - 在Visual Studio中,以您要保护的配置(例如, AnyCPU | Release )构建您的项目一次.将会出错,因为新的配置文件尚无任何输入程序集,但是通过现在构建,我们将这些程序集放置在正确的位置来配置Dotfuscator.
- 打开Dotfuscator的用户界面.
- 对于Community Edition,从Visual Studio中,打开工具"菜单,然后选择"PreEmptive Protection-Dotfuscator".
- 对于Professional Edition,请从开始"菜单中运行Dotfuscator Professional Edition.
- In the targets file, locate the
_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. - 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.
- 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中,转到"构建设置"屏幕,然后选择"项目属性"标签.
- 在专业版中,转到"设置"标签,然后选择"设置>项目属性"屏幕.
- 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
,值obj\Release\DotfuscatorXamarin\dfin
- 属性名称
OutDir
,值obj\Release\DotfuscatorXamarin\dfout
- 属性名称
ReportDir
,值DotfuscatorReports\Release
- 用用于在步骤2中构建的配置的适当目录替换
Release
.请注意,OutDir
和ReportDir
指向的目录在磁盘上尚不存在.
- Property name
InDir
, valueobj\Release\DotfuscatorXamarin\dfin
- Property name
OutDir
, valueobj\Release\DotfuscatorXamarin\dfout
- Property name
ReportDir
, valueDotfuscatorReports\Release
- Substitute
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.
这篇关于Xamarin.Android项目上的Dotfuscator抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!