Error when obfuscate Winforms library that targets .Net FW4.7 and NetCore3.1
hans_n
Posts: 3 New member
Hi there,
I'm configuring my csproj file to obfuscate dlls but it always fails with msg:
ERROR: Cannot find dependency 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', which is required for assembly:
xxxxx, Version=4.7.20202.44, Culture=neutral, PublicKeyToken=xxxxxxx
Here is my csproj file
I'm configuring my csproj file to obfuscate dlls but it always fails with msg:
ERROR: Cannot find dependency 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', which is required for assembly:
xxxxx, Version=4.7.20202.44, Culture=neutral, PublicKeyToken=xxxxxxx
Here is my csproj file
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<Configurations>Debug;Release;Release2</Configurations>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>TestLib</RootNamespace>
<AssemblyName>TestLib</AssemblyName>
<EnableDefaultCompileItems>False</EnableDefaultCompileItems>
<UseWindowsForms>True</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>
<!-- SmartAssembly task -->
<Target Name="SetSmartAssemblyProjectPathForEachTarget" BeforeTargets="BuildWithSmartAssembly" Condition="('$(Configuration)' == 'Release' or '$(Configuration)' == 'Release2') and ('$(TargetFramework)' != '')">
<PropertyGroup>
<SmartAssemblyProjectFile>$(MSBuildProjectDirectory)\SA_Obfuscation\$(AssemblyName)_$(Configuration)_$(TargetFramework).{sa}proj</SmartAssemblyProjectFile>
</PropertyGroup>
<Message Importance="High" Text="SmartAssembly project for '$(Configuration)/$(TargetFramework)' set to: $(SmartAssemblyProjectFile)" />
</Target>
<PropertyGroup>
<SmartAssemblyOverwriteAssembly>true</SmartAssemblyOverwriteAssembly>
<_SATaskAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">SmartAssembly.MSBuild.Tasks_NetStandard, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57</_SATaskAssembly>
<_SATaskAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">SmartAssembly.MSBuild.Tasks, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57</_SATaskAssembly>
</PropertyGroup>
<UsingTask TaskName="SmartAssembly.MSBuild.Tasks.Build" AssemblyName="$(_SATaskAssembly)" Condition="('$(Configuration)' == 'Release' or '$(Configuration)' == 'Release2') and ('$(TargetFramework)' != '')" />
<Target Name="BuildWithSmartAssembly" AfterTargets="Build" Condition="('$(Configuration)' == 'Release' or '$(Configuration)' == 'Release2') and ('$(TargetFramework)' != '')">
<SmartAssembly.MSBuild.Tasks.Build ProjectFile="$(SmartAssemblyProjectFile)" />
</Target>
<!-- /SmartAssembly task -->
</Project>
Could you please take a look and let me know how to fix it? Thanks!
Could you please take a look and let me know how to fix it? Thanks!
Tagged:
Answers
Is the netstandard.dll library somewhere inside C:\Program Files\dotnet\sdk?
It's fine to obfuscate only net472 alone.
It also fails when obfuscate only netcoreapp3.0 or netcoreapp3.1. And there's no official netcoreapp3.2 yet, right?