【问题标题】:Dotfuscator netstandard project using Dotfuscator community only仅使用 Dotfuscator 社区的 Dotfuscator netstandard 项目
【发布时间】:2019-07-17 20:01:46
【问题描述】:

正如标题所说,我正在尝试将Dotfuscator community 与 netstandard 项目一起使用。

我已经通过关注this 完成了 xamarin 项目

它并不真正适用于 netstandard 和 net core 项目。

对于 net standard2.0,我尝试使用 this guid,但我使用的是 Visual Studio 2019 中包含的免费版本。我找不到 PreEmptive.Dotfuscator.Common.targets

那么你知道我可以使用命令行之类的设置吗?

这是我尝试过的。 配置.xml

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This config file was generated by Dotfuscator. Please use the Dotfuscator Config Editor to modify.-->
<!DOCTYPE dotfuscator SYSTEM "http://www.preemptive.com/dotfuscator/dtd/dotfuscator_v2.5.dtd">
<dotfuscator version="2.3">
  <global>
    <option>debugauto</option>
  </global>
  <input>
    <loadpaths />
    <asmlist>
      <inputassembly refid="a1403c2e-befc-47f7-b609-503ab5bb2ab2">
        <option>honoroas</option>
        <option>stripoa</option>
        <option>library</option>
        <option>transformxaml</option>
        <file dir="E:\Projects\Youtube.Manager\Youtube.Manager.Models.Container\bin\Release\netcoreapp2.2" name="Youtube.Manager.Models.Container.dll" />
      </inputassembly>
    </asmlist>
  </input>
  <output>
    <!--<file dir="${configdir}\Dotfuscated" />-->
    <file dir="${configdir}\Dotfuscated" />
  </output>
  <renaming>
    <option>xmlserialization</option>
    <mapping>
      <mapoutput overwrite="true">
        <file dir="${configdir}\Dotfuscated" name="Map.xml" />
      </mapoutput>
    </mapping>
    <referencerulelist>
      <referencerule rulekey="{6655B10A-FD58-462d-8D4F-5B1316DFF0FF}" />
      <referencerule rulekey="{7D9C8B02-2383-420f-8740-A9760394C2C1}" />
      <referencerule rulekey="{229FD6F8-5BCC-427b-8F72-A7A413ECDF1A}" />
      <referencerule rulekey="{2B7E7C8C-A39A-4db8-9DFC-6AFD38509061}" />
      <referencerule rulekey="{494EA3BA-B947-44B5-BEE8-A11CC85AAF9B}" />
      <referencerule rulekey="{89769974-93E9-4e71-8D92-BE70E855ACFC}" />
      <referencerule rulekey="{4D81E604-A545-4631-8B6D-C3735F793F80}" />
      <referencerule rulekey="{62bd3899-7d53-4336-8ca2-4e5dbae187d5}" />
    </referencerulelist>
  </renaming>
  <sos mergeruntime="true">
    <option>version:v4</option>
    <option>sendanalytics</option>
    <option>dontsendtamper</option>
  </sos>
  <smartobfuscation>
    <smartobfuscationreport verbosity="all" overwrite="true" />
  </smartobfuscation>
</dotfuscator>

项目内部

  <Target Name="CustomAfterBuild" AfterTargets="AfterBuild" >
    <Message Text="Should run after build" Importance="High" />
    <Exec Command="&quot;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE\dotfuscatorCLI.exe&quot; Dotfuscator.xml" />
  </Target>

我得到了错误

Severity    Code    Description Project File    Line    Suppression State
Error   MSB3073 The command ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE\dotfuscatorCLI.exe" Dotfuscator.xml" exited with code 1.    Youtube.Manager.Models.Container    E:\Projects\Youtube.Manager\Youtube.Manager.Models.Container\Youtube.Manager.Models.Container.csproj    34  

日志

1>Should run after build
1>Youtube.Manager.Models.Container -> E:\Projects\Youtube.Manager\Youtube.Manager.Models.Container\bin\Release\netcoreapp2.2\Youtube.Manager.Models.Container.dll
1>Should run after build
1>Dotfuscator Community Version 5.42.0.9514-e0e25f754
1>Copyright 2002-2019 PreEmptive Solutions, LLC All Rights Reserved.
1>Use of this software implies acceptance of accompanying license agreement.
1>
1>Dotfuscator Community Version 5.42.0.9514-e0e25f754
1>Copyright 2002-2019 PreEmptive Solutions, LLC All Rights Reserved.
1>Use of this software implies acceptance of accompanying license agreement.
1>
1>For personal use only. Please refer to the EULA distributed with The Software for details.
1>
1>For personal use only. Please refer to the EULA distributed with The Software for details.
1>
1>[Build Output] Loading Assemblies...
1>[Build Output]
1>[Build Output] Loading Assemblies...
1>[Build Output]
1>[Build Output] Running C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\ildasm.exe /OUT=C:\Users\alent\AppData\Local\Temp\~Youtube.9\Youtube.Manager.Models.Container.dll.il /TEXT /NOBAR /RAWEH /QUOTEALLNAMES /UTF8  /FORWARD E:\Projects\Youtube.Manager\Youtube.Manager.Models.Container\bin\Release\netcoreapp2.2\Youtube.Manager.Models.Container.dll
1>[Build Output]
1>[Build Output] Running C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\ildasm.exe /OUT=C:\Users\alent\AppData\Local\Temp\~Youtube.11\Youtube.Manager.Models.Container.dll.il /TEXT /NOBAR /RAWEH /QUOTEALLNAMES /UTF8  /FORWARD E:\Projects\Youtube.Manager\Youtube.Manager.Models.Container\bin\Release\netcoreapp2.2\Youtube.Manager.Models.Container.dll
1>[Build Output]
1>[Build Output] Read debugging symbols for module 'Youtube.Manager.Models.Container.dll'.
1>[Build Output] Read debugging symbols for module 'Youtube.Manager.Models.Container.dll'.
1>[Build Output]
1>[Build Output]
1>[Build Output] Processing instrumentation attributes...
1>[Build Output] Processing instrumentation attributes...
1>EXEC : [Build Output] warning : No SetupAttribute was found. Messages will not be sent for any configured analytics messages and/or checks.
1>EXEC : [Build Output] warning : No SetupAttribute was found. Messages will not be sent for any configured analytics messages and/or checks.
1>[Build Output]
1>[Build Output]
1>[Build Output] Analyzing Markup...
1>[Build Output] Analyzing Markup...
1>[Build Output]
1>[Build Output] Renaming...
1>[Build Output]
1>[Build Output]
1>[Build Output] Renaming...
1>[Build Output]
1>[Build Output] Updating Markup...
1>[Build Output]
1>[Build Output] Updating Markup...
1>[Build Output]
1>[Build Output] Writing map file to E:\Projects\Youtube.Manager\Youtube.Manager.Models.Container\Dotfuscated\Map.xml
1>[Build Output]
1>[Build Output] Writing map file to E:\Projects\Youtube.Manager\Youtube.Manager.Models.Container\Dotfuscated\Map.xml
1>[Build Output]
1>[Build Output] The process cannot access the file 'E:\Projects\Youtube.Manager\Youtube.Manager.Models.Container\Dotfuscated\Map.xml' because it is being used by another process.
1>[Build Output] Build Error.
1>[Build Output] Writing Assemblies...
1>[Build Output]
1>E:\Projects\Youtube.Manager\Youtube.Manager.Models.Container\Youtube.Manager.Models.Container.csproj(34,5): error MSB3073: The command ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE\dotfuscatorCLI.exe" Dotfuscator.xml" exited with code 1.
1>Done building project "Youtube.Manager.Models.Container.csproj" -- FAILED.
1>[Build Output] Running C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ilasm.exe /OUTPUT=C:\Users\alent\AppData\Local\Temp\~Youtube.9\stub-pdb\Youtube.Manager.Models.Container.dll /nologo  /quiet /dll  /PDB /resource=C:\Users\alent\AppData\Local\Temp\~Youtube.9\Youtube.Manager.Models.Container.dll.res C:\Users\alent\AppData\Local\Temp\~Youtube.9\Youtube.Manager.Models.Container.dll.il
1>[Build Output]
1>[Build Output]
1>[Build Output]
1>[Build Output] Wrote assembly "E:\Projects\Youtube.Manager\Youtube.Manager.Models.Container\bin\Release\netcoreapp2.2\Youtube.Manager.Models.Container.dll" to "E:\Projects\Youtube.Manager\Youtube.Manager.Models.Container\Dotfuscated\Youtube.Manager.Models.Container.dll"
1>[Build Output]
1>[Build Output]
1>[Build Output] Build Finished.
1>[Build Output]
1>[Build Output]
1>[Build Output] Types Renamed:  21 of 81  (25.93%)
1>[Build Output] Methods Renamed:  50 of 454  (11.01%)
1>[Build Output] Fields Renamed:  219 of 307  (71.34%)
1>[Build Output]
1>[Build Output] You might see better renaming results by disabling Library Mode for one or more of your assemblies.
1>[Build Output] Please see https://www.preemptive.com/dotfuscator/ce/docs/help/obfuscation_overview.html#library-mode
1>[Build Output] for additional information about enabling Library Mode and how to configure renaming exclusions.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

【问题讨论】:

  • 我无法重现您的问题。您的目标 CustomAfterBuild 似乎以某种方式运行了两次,因为重复了几行日志记录,并且该错误似乎与尝试同时写入 map file 的多个 Dotfuscator 实例有关。

标签: visual-studio .net-core .net-standard-2.0 dotfuscator


【解决方案1】:

您提到的MSBuild integration 是Dotfuscator Professional 独有的。

Dotfuscator 社区有一个 separate integration exclusive for Xamarin apps,包括那些引用 .NET 标准库的。

对于其他平台,Dotfuscator 社区仅支持“构建后”方案,您可以在已构建的程序集(.dll.exe 文件)上运行 Dotfuscator。 您将需要使用 Dotfuscator Community user interface 创建 Dotfuscator 配置文件(例如,Dotfuscator.xml),指定哪些程序集应为 inputs to Dotfuscator。然后,您可以在构建结束时通过自定义步骤调用 Dotfuscator Community command line,以生成受保护的程序集版本。

注意:我在 Dotfuscator 团队工作,并在我的工作中回答这个问题。)

【讨论】:

  • 感谢帮助人员,我阅读了这个命令行,但正如我所说,我对此真的很陌生,并且您提供的链接没有详细说明如何创建此配置文件以及如何触发项目文件中的命令行等。能否请您提供,这里或那里的设置。这对我和其他人真的很有帮助。
  • 记住我最感兴趣的是 dll 而不是 exe 文件
  • 我更新了我的 Q,如果你能帮助我理解为什么我会得到这个错误,请看上面。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-26
  • 2019-06-17
  • 2020-09-15
  • 2020-04-11
  • 2018-03-14
  • 1970-01-01
相关资源
最近更新 更多