首页 > 解决方案 > 仅使用 Dotfuscator 社区的 Dotfuscator netstandard 项目

问题描述

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

我已经通过 xamarin 项目完成了这个

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

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

所以你知道我可以使用命令行或其他东西的设置吗?

这是我尝试过的。配置文件

<?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 ==========

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

解决方案


您提到的MSBuild 集成是 Dotfuscator Professional 独有的。

Dotfuscator 社区有一个单独的集成,专门用于 Xamarin 应用程序,包括那些引用 .NET 标准库的应用程序。

对于其他平台,Dotfuscator 社区仅支持“构建后”方案,您可以在已构建的程序集(.dll.exe文件)上运行 Dotfuscator。您将需要使用Dotfuscator Community 用户界面创建一个 Dotfuscator 配置文件(例如Dotfuscator.xml),指定哪些程序集应作为Dotfuscator 的输入。然后,您可以在构建结束时从自定义步骤调用Dotfuscator Community 命令行,以生成受保护的程序集版本。

注意:我为 Dotfuscator 团队工作,我将回答这个问题作为我工作的一部分。)


推荐阅读