我正在将现有Xamarin应用程序从PCL升级到.NET Standard 2.0。 我有几个子项目,例如业务,数据,BDO等,它们是PCL,我已经能够使用this tutorial将它们更新到.NET Standard 2.0。
但是,我已经使用this Xamarin Blog实现在所有PCL项目上实现了Dotufscator,但是它似乎不能作为.NET Standard 2.0项目的说明。不会混淆DLL,并且“正在运行Dotfuscator”消息不会显示在“生成输出”中。
我目前将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>
任何人都可以提供帮助吗? 谢谢
答案 0 :(得分:2)
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. I also wrote the blog post you linked to, so I'm glad you've found it valuable in protecting your Xamarin app.
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. Integrating directly into library projects like Portable Class Libraries (PCLs) or .NET Standard Libraries isn't supported.
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.
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.
This approach allows for stronger protection and doesn't require you to run Dotfuscator for each library separately, saving you build and configuration time.
If you are using the commercially-licensed Dotfuscator Professional Edition, version 4.37.0 includes a new MSBuild integration. 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. I recommend upgrading Dotfuscator to this version and removing the Dotfuscator-Xamarin MSBuild integration from your .NET Standard projects. Then, add the new MSBuild integration to your platform-specific Xamarin projects; for details, see the Xamarin Getting Started page of our User Guide.
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. I recommend you remove the integration from your .NET Standard Libraries and instead add it into the platform-specific Xamarin projects that reference them. 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); see this answer for a workaround. Subsequent builds will occur normally without needing a workaround.