Options

SmartAssembly 7.5 - Issue with .NET Core references version

UrosJovUrosJov Posts: 3 New member
edited November 30, 2020 4:12PM in SmartAssembly
Hi,

We stumbled upon an issue when obfuscating .NET Core class library projects. When built in Debug without using SA, the reflected DLL looks like this:



But when built in Release and obfuscated with SA, the same DLL looks like this:



This causes a compile-time warning when this obfuscated library gets referenced in another project (such as Asp.Net Core webapp), like this:
2>------ Rebuild All started: Project: WebApp, Configuration: Release Any CPU ------
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3277: Found conflicts between different versions of "Microsoft.AspNetCore.Authentication.Abstractions" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3277: Found conflicts between different versions of "Microsoft.AspNetCore.Authentication" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3277: Found conflicts between different versions of "Microsoft.AspNetCore.Authorization.Policy" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3277: Found conflicts between different versions of "Microsoft.AspNetCore.Authorization" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3277: Found conflicts between different versions of "Microsoft.Extensions.Caching.Memory" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3277: Found conflicts between different versions of "Microsoft.Extensions.DependencyInjection.Abstractions" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3277: Found conflicts between different versions of "Microsoft.Extensions.Http" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
In some cases it even leads to compile-time or run-time errors. Looking a bit more into details of SA build logs, I found a line which clearly states that the dependency resolver chose the 3.1.9 version of the runtime (although I have both 3.1.0 and 3.1.9 available):
SmartAssembly.AssemblyReader: Resolved assembly {Microsoft.AspNetCore.Authentication, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60} to C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App\3.1.9\Microsoft.AspNetCore.Authentication.dll
On another machine, where 3.1.3 runtime is installed it resolved to that, so basically all the references got switched from 3.1.0.0 to 3.1.3.0. This behavior is really odd, and it basically disables us from using the obfuscation in such cases because it will either fail the build or even worse, fail the app in runtime.

The version of SmartAssembly is the latest 7.5.2 and the latest Visual Studio 2019 (16.8.2). Also, attached below is a minimal case for repro.

Please advise on how we can resolve this issue, or is there some workaround at least.

Best regards


Comments

Sign In or Register to comment.