简体   繁体   English

如何在.NET Standard 2.0项目上实现Dotfuscator?

[英]How can I implement Dotfuscator on a .NET Standard 2.0 project?

I'm in the process of of upgrading an existing Xamarin app from PCL to .NET Standard 2.0. 我正在将现有的Xamarin应用程序从PCL升级到.NET Standard 2.0。 I have several sub-projects such as business, data, BDO etc. which were PCL, I've been able to update them to .NET Standard 2.0 using this tutorial . 我有几个子项目,如业务,数据,BDO等PCL,我已经能够使用本教程将它们更新为.NET Standard 2.0。

However I have Dotufscator implemented on all my PCL projects using this Xamarin Blog implementation, but it does not appear to work as an instruction for .NET Standard 2.0 projects. 但是我使用这个Xamarin Blog实现在我的所有PCL项目上实现了Dotufscator,但它似乎不能用作.NET Standard 2.0项目的指令。 The DLL is not obfuscated and the 'Running Dotfuscator' message does not show in the Build Output. DLL未被混淆,并且“运行Dotfuscator”消息未显示在构建输出中。

My current attempt at adding Dotufcator to a .NET Standard 2.0 proj file is as follows: 我目前尝试将Dotufcator添加到.NET Standard 2.0 proj文件中的尝试如下:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <DotfuscatorXamarinCliPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\PreEmptiveSolutions\DotfuscatorCE\dotfuscatorCLI.exe</DotfuscatorXamarinCliPath>
    <DotfuscatorXamarinConfigFileName>DotfuscatorConfig.xml</DotfuscatorXamarinConfigFileName>
    <DotfuscatorXamarinGenerateNewConfigFile>true</DotfuscatorXamarinGenerateNewConfigFile>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <OutputPath>bin\Debug\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DotfuscatorXamarinEnabled>true</DotfuscatorXamarinEnabled>
    <OutputPath>bin\Release\</OutputPath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
  </ItemGroup>
  <ItemGroup>
    <None Include="DotfuscatorConfig.xml" />
  </ItemGroup>

  <Import Project="..\PreEmptive.Dotfuscator.Xamarin.targets" />
</Project>

Would anyone be able to help? 有人能帮忙吗? Thanks 谢谢

As a disclaimer, I should mention I'm answering this post as part of my job as a developer and technical writer on the Dotfuscator team. 作为免责声明,我应该提到我正在回答这篇文章,作为Dotfuscator团队的开发人员和技术作家的一部分。 I also wrote the blog post you linked to , so I'm glad you've found it valuable in protecting your Xamarin app. 我还写了你链接的博客文章 ,所以我很高兴你发现它在保护你的Xamarin应用程序方面很有价值。

First, there's an ambiguity in the blog post that I should clear up. 首先,我应该清理博客文章中的含糊不清。 The Dotfuscator-Xamarin MSBuild integration shown there is only intended to be integrated into platform-specific Xamarin projects which build into a packaged format, like an Android project that builds an APK. 显示的Dotfuscator-Xamarin MSBuild集成仅用于集成到特定于平台的Xamarin项目中,这些项目构建为打包格式,如构建APK的Android项目。 Integrating directly into library projects like Portable Class Libraries (PCLs) or .NET Standard Libraries isn't supported. 不支持直接集成到可移植类库(PCL)或.NET标准库等库项目中。

Note that integrating Dotfuscator into a Xamarin project will protect all packaged assemblies that originated from your solution, so your library code will still be protected. 请注意,将Dotfuscator集成到Xamarin项目中将保护源自解决方案的所有打包程序集,因此您的库代码仍将受到保护。 For instance, if you integrate Dotfuscator into MyApp.Android.csproj , which references A.csproj , B.csproj , and C.csproj , Dotfuscator will protect all four projects' assemblies when they are packaged into the APK. 举例来说,如果你整合到Dotfuscator的MyApp.Android.csproj ,它引用A.csprojB.csprojC.csproj ,Dotfuscator的将保护所有四个项目的组件时,它们被打包成APK。 This approach allows for stronger protection and doesn't require you to run Dotfuscator for each library separately, saving you build and configuration time. 这种方法可以提供更强大的保护,并且不需要您单独为每个库运行Dotfuscator,从而节省了构建和配置时间。

If you are using the commercially-licensed Dotfuscator Professional Edition , version 4.37.0 includes a new MSBuild integration . 如果您使用的是商业许可的Dotfuscator专业版 ,则版本4.37.0包含一个新的MSBuild集成 The new integration is easier to set up, fixes some known issues, and going forward will be the primary way we recommend using Dotfuscator, for projects of all kinds, not just Xamarin. 新的集成更容易设置,修复一些已知问题,并且将继续推进将是我们推荐使用Dotfuscator的主要方式,适用于各种项目,而不仅仅是Xamarin。 I recommend upgrading Dotfuscator to this version and removing the Dotfuscator-Xamarin MSBuild integration from your .NET Standard projects. 我建议将Dotfuscator升级到此版本,并从.NET Standard项目中删除Dotfuscator-Xamarin MSBuild集成。 Then, add the new MSBuild integration to your platform-specific Xamarin projects; 然后,将新的MSBuild集成添加到特定于平台的Xamarin项目中; for details, see the Xamarin Getting Started page of our User Guide. 有关详细信息,请参阅我们的用户指南的Xamarin入门页面

If you are using Dotfuscator Community Edition (included with all Visual Studio editions) or an older Professional Edition, please continue to use the Dotfuscator-Xamarin MSBuild integration mentioned by the blog post. 如果您使用的是Dotfuscator Community Edition (包含在所有Visual Studio版本中)或较旧的专业版,请继续使用博客文章中提到的Dotfuscator-Xamarin MSBuild集成 I recommend you remove the integration from your .NET Standard Libraries and instead add it into the platform-specific Xamarin projects that reference them. 我建议您从.NET标准库中删除集成,然后将其添加到引用它们的特定于平台的Xamarin项目中。 Note that when integrating into a Xamarin project that references .NET Standard Libraries, there is a known issue where the first build will fail (because the integration doesn't understand the minimal project format .NET Standard uses); 请注意,当集成到引用.NET标准库的Xamarin项目时,存在一个已知问题,即第一个构建将失败(因为集成不理解.NET Standard使用的最小项目格式); see this answer for a workaround. 看到这个答案的解决方法。 Subsequent builds will occur normally without needing a workaround. 后续构建将正常进行而无需解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在.NET 2.0中实现自定义属性? - How can I implement custom attributes in .NET 2.0? 如何在.net 2.0项目中使用.net 3.0类? - How can I use .net 3.0 class in .net 2.0 project? 我可以使用在.NET Standard 2.0中为.NET Framework编写的包吗? - Can I use packages written for .NET Framework in .NET Standard 2.0? 如何在 Visual Studio 2022 和 .net Standard 2.0 或 .net 4.8 中使用 CallerArgumentExpression? - How can I use CallerArgumentExpression with Visual Studio 2022 and .net Standard 2.0 or .net 4.8? 为什么 .NET 框架项目可以作为参考添加到 .NET 标准 2.0 项目中? - Why .NET framework project can be added as reference in .NET Standard 2.0 project? 如何使用.Net Standard 2.0将Excel文件转换为pdf - How can I convert excel file to pdf using .Net Standard 2.0 如何在.NET Standard 2.0映射中指定删除时不执行任何操作? PostgreSQL的 - How can I specify on delete no action in .NET Standard 2.0 mapping? PostgreSQL 在.Net标准2.0项目中添加dll参考 - Adding dll reference in .Net standard 2.0 project 尽管我具有.NET core 2.2,但如何打开.NET core 2.0 mvc项目? - How can I open a .NET core 2.0 mvc project despite that I have .NET core 2.2? 我可以从 UWP 项目引用到 .NET 标准项目吗? - Can I refer from a UWP project to a .NET Standard project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM