PreEmptive Dotfuscator不使用Xamarin

时间:2018-02-13 09:40:33

标签: xamarin obfuscation dotfuscator

我正在使用PreEmptive Obfuscator(Dotfuscator)来混淆Xamarin应用程序。 我的问题是Obfuscator不会混淆我的项目dll。当我在混淆后打开dll时,我仍然看到可读的信息。单击构建/重建按钮时,混淆工具会自动打开 - 这证明我已正确链接/配置它。

可能是什么问题?请参阅下面的屏幕截图:

enter image description here

我的项目文件代码:

  <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
   <DotfuscatorXamarinCliPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE\dotfuscatorCLI.exe</DotfuscatorXamarinCliPath>
    <DotfuscatorXamarinConfigFileName>DotfuscatorConfig.xml</DotfuscatorXamarinConfigFileName>
    <DotfuscatorXamarinGenerateNewConfigFile>true</DotfuscatorXamarinGenerateNewConfigFile> 

    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.30703</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{88F1AA1B-4608-40F7-B14D-C7E28099A26E}</ProjectGuid>
    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>TestDotObfuscator</RootNamespace>
    <AssemblyName>TestDotObfuscator</AssemblyName>
    <FileAlignment>512</FileAlignment>
    <AndroidApplication>True</AndroidApplication>
    <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
    <AndroidResgenClass>Resource</AndroidResgenClass>
    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
    <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
    <TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
    <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
    <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
    <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>True</DebugSymbols>
    <DebugType>Full</DebugType>
    <Optimize>False</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
    <AndroidLinkMode>None</AndroidLinkMode>
    <EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
    <AotAssemblies>false</AotAssemblies>
    <EnableLLVM>false</EnableLLVM>
    <BundleAssemblies>false</BundleAssemblies>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DotfuscatorXamarinEnabled>true</DotfuscatorXamarinEnabled> 
    <DebugSymbols>True</DebugSymbols>
    <DebugType>PdbOnly</DebugType>
    <Optimize>True</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidManagedSymbols>true</AndroidManagedSymbols>
    <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
    <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
    <AotAssemblies>false</AotAssemblies>
    <EnableLLVM>false</EnableLLVM>
    <BundleAssemblies>false</BundleAssemblies>
    <AndroidCreatePackagePerAbi>true</AndroidCreatePackagePerAbi>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Core" />
    <Reference Include="Mono.Android" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="DB.cs" />
    <Compile Include="MainActivity.cs" />
    <Compile Include="Resources\Resource.Designer.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="GettingStarted.Xamarin" />
    <None Include="Resources\AboutResources.txt" />
    <None Include="Properties\AndroidManifest.xml" />
    <None Include="Assets\AboutAssets.txt" />
  </ItemGroup>
  <ItemGroup>
    <AndroidResource Include="Resources\layout\Main.axml">
      <SubType>Designer</SubType>
    </AndroidResource>
    <AndroidResource Include="Resources\values\Strings.xml" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Resources\drawable\" />
    <Folder Include="Resources\mipmap-hdpi\" />
    <Folder Include="Resources\mipmap-mdpi\" />
    <Folder Include="Resources\mipmap-xhdpi\" />
    <Folder Include="Resources\mipmap-xxhdpi\" />
    <Folder Include="Resources\mipmap-xxxhdpi\" />
  </ItemGroup>
  <ItemGroup>
    <None Include="DotfuscatorConfig.xml" />
  </ItemGroup>
  <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
        <Target Name="BeforeBuild">
        </Target>
        <Target Name="AfterBuild">
        </Target>
    -->
  <Import Project="..\..\PreEmptive.Dotfuscator.Xamarin.targets" />
</Project>

2 个答案:

答案 0 :(得分:1)

安装Dotfuscator Community Edition时(在您的情况下为C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE),dotfuscator.exe是图形用户界面(GUI),dotfuscatorCLI.exe是命令行界面(CLI)。 (专业版的名称和路径不同。)

根据您编辑的问题和对评论的回复,您似乎以某种方式将dotfuscatorCLI.exe替换为dotfuscator.exe的副本。当Visual Studio构建集成调用dotfuscatorCLI.exe时,它需要运行命令行,而不是GUI。

请卸载,然后重新安装Dotfuscator Community Edition:

  1. 关闭Visual Studio 2017的所有实例。
  2. 从“开始”菜单中,打开Visual Studio Installer。
  3. 在&#34; Visual Studio社区2017&#34;下,选择修改(可能在更多下拉菜单下)。
  4. 选择个人组件标签。
  5. 向下滚动到代码工具部分,取消选中 PreEmptive Protection - Dotfuscator 框。
  6. 点击修改
  7. 卸载完成后,再次打开修改
  8. 选择个人组件标签。
  9. 向下滚动到代码工具部分,然后选中 PreEmptive Protection - Dotfuscator 框。
  10. 点击修改
  11. 安装完成后,打开命令提示符。
  12. 运行:cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE"
  13. 运行:dotfuscator.exe
  14. 验证图形用户界面(GUI)是否打开。
  15. 返回命令提示符并运行:dotfuscatorCLI.exe
  16. 验证帮助文本是否显示在命令提示符中,并且图形用户界面(GUI)不会打开。
  17. 然后,假设您已注册Community Edition,您应该能够在Visual Studio中运行Dotfuscator集成的Xamarin构建,并且当您这样做时,GUI应该打开。

    免责声明:正如评论中所提到的,我也在Dotfuscator团队工作,并且正在以这种身份回答这个问题。

答案 1 :(得分:0)

听起来好像您可能将集成配置为使用GUI可执行文件,而不是CLI(构建)可执行文件。如果您在每次构建Xamarin应用程序时都看到Dotfuscator GUI,那可能就是问题所在。

根据您使用的是Dotfuscator Community Edition还是Dotfuscator Professional,可执行文件名称可能不同。对于CE,请使用dotfuscatorCLI.exe。对于Pro,请使用dotfuscator.exe

完全披露:我为制作Dotfuscator的公司PreEmptive Solutions工作。