c# - 尝试构建 .Net Core 控制台应用程序时出现 Dotfuscator 错误
问题描述
我有一个简单的 .Net Core 控制台应用程序,并试图使用Dotfuscator Community
工具https://www.preemptive.com/dotfuscator/ce/docs/help/index.html混淆生成的 dll :
class Program
{
public static void Main()
{
Console.Write("\n\nFunction to calculate the sum of two numbers :\n");
Console.Write("--------------------------------------------------\n");
Console.Write("Enter a number: ");
int n1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter another number: ");
int n2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\nThe sum of two numbers is : {0} \n", Sum(n1, n2));
Console.ReadKey();
}
public static int Sum(int num1, int num2)
{
int total;
total = num1 + num2;
return total;
}
}
从Add Input
选项中选择生成的 dll 后,当我尝试使用该选项构建它时,虽然程序在我的本地成功构建Build
,但我得到(下面的屏幕截图)。Build Error
bin -> Debug -> netcoreapp3.1
显然,从错误来看,文件夹内的 System.Runtime 似乎丢失了;所以我将它安装在我的应用程序中,但错误仍然存在。
我的 .csproj 文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Obfuscar" Version="2.2.28">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Runtime" Version="4.3.1" />
</ItemGroup>
</Project>