mkaring / ConfuserEx

An open-source, free protector for .NET applications
https://mkaring.github.io/ConfuserEx/
MIT License
2.31k stars 350 forks source link

dnlib is not found when building in a pipelin using Confuser.MSBuild 1.6.0 #477

Closed Kratheon closed 2 years ago

Kratheon commented 2 years ago

Steps to Reproduce:

  1. Create a pipeline in Azure Devops or any CI Pipeline in general
  2. Build the project where you integrated the confuser.MsBuild in order to obfusacte the .dll generated by the build process

ConfuserMSBuildErrorCSPROJ ConfuserMSBuildErrorReferences ConfuserMSBuildError

As you can see in the last image, it seems that during the ConfuseTask in the building process of a pipeline, ConfuserEx is not able to find the dnlib.dll

I don't have this problem when I build the project in Visual Studio 2022.

I aldready tried to give the dnlib.dll (v.3.4.0) by adding it in the project root (and copy it in the output directory in the csproj)or adding a probePath in the crproj giving the path of dnlib.dll

Any ideas what I am missing or it is even possible to use Confuser.MsBuild in a pipeline building process ?

mkaring commented 2 years ago

My best guess is that your build pipeline is running using the .NET Core version of MSBuild instead of the full version. The .NET Core version does not work with ConfuserEx yet. Only the full msbuild that is part of Visual Studio and the Visual Studio Build Tools works correctly.

jkarpio commented 2 years ago

Jetbrain Rider, .NET4.8 with new project format, using Microsoft Build Engine version 17.1.0+ae57d105c for .NET

Confuser.MSBuild.targets(74, 5): [MSB4018] The "Confuser.MSBuild.Tasks.ConfuseTask" task failed unexpectedly. System.AggregateException: One or more errors occurred. (Could not load file or assembly 'dnlib, Version=3.4.0.0, Culture=neutral, PublicKeyToken=50e96378b6e77999'. The system cannot find the file specified. ) ---> System.IO.FileNotFoundException: Could not load file or assembly 'dnlib, Version=3.4.0.0, Culture=neutral, PublicKeyToken=50e96378b6e77999'. The system cannot find the file specified. File name: 'dnlib, Version=3.4.0.0, Culture=neutral, PublicKeyToken=50e96378b6e77999' at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) at Confuser.Core.ConfuserEngine.<>c__DisplayClass3_0.b__0() in C:\projects\confuserex\Confuser.Core\ConfuserEngine.cs:line 69 at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Confuser.MSBuild.Tasks.ConfuseTask.Execute() in C:\projects\confuserex\Confuser.MSBuild.Tasks\ConfuseTask.cs:line 33 at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)

Kratheon commented 2 years ago

My best guess is that your build pipeline is running using the .NET Core version of MSBuild instead of the full version. The .NET Core version does not work with ConfuserEx yet. Only the full msbuild that is part of Visual Studio and the Visual Studio Build Tools works correctly.

Yeah, it seems it was that. Msbuild 17.1 worked fine in the pipeline. Thanks for the answer ! :D

github-actions[bot] commented 2 years ago

This issue needs more information and has not had recent activity. Please provide the missing information or it will be closed in 7 days. Thanks!

Dimitory commented 2 years ago

I've fixed this for me - https://github.com/mkaring/ConfuserEx/pull/488 Could you publish nuget package asap?:)

github-actions[bot] commented 2 years ago

This issue needs more information and has not had recent activity. Please provide the missing information or it will be closed in 7 days. Thanks!

github-actions[bot] commented 2 years ago

Closing this issue because it needs more information and has not had recent activity. Please re-open this issue if more details can be provided. Thanks!

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.