dsplaisted / strongnamer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build failling only when using "dotnet publish" from command line

eyaldar opened this issue · comments

Hi,

I've been having this issue where I'm getting this error:
error MSB4018: The "StrongNamer.AddStrongName" task failed unexpectedly. C:\Users\eyal.darshan\.nuget\packages\strongnamer\0.2.5\build\StrongNamer.targets(30,5): error MSB4018: System.MissingMethodException: Method not found: 'Void Mono.Cecil.WriterParameters.set_StrongNameKeyBlob(Byte[])'. C:\Users\eyal.darshan\.nuget\packages\strongnamer\0.2.5\build\StrongNamer.targets(30,5): error MSB4018: at StrongNamer.AddStrongName.ProcessAssembly(ITaskItem assemblyItem, Byte[] keyBytes, StrongNamerAssemblyResolver resolver) C:\Users\eyal.darshan\.nuget\packages\strongnamer\0.2.5\build\StrongNamer.targets(30,5): error MSB4018: at StrongNamer.AddStrongName.Execute() C:\Users\eyal.darshan\.nuget\packages\strongnamer\0.2.5\build\StrongNamer.targets(30,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() C:\Users\eyal.darshan\.nuget\packages\strongnamer\0.2.5\build\StrongNamer.targets(30,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)

I tried ignoring it and turned off "warning as error" but nothing seems to work.
the only packages I need signed are : SQLKata and GraphQL.
everything works perfectly in visual studio, it only fails when I try to use dotnet build/dotnet publish and only for a specific ASP .NET CORE project.

After some investigation it seems that ASP .NET CORE is defined as MSBuildRuntimeType == 'Full' which directs the task to net461 instead of .netcoreapp2.1 which causes everything to break.

commented

@eyaldar how did you fix the issue? I'm facing a similar issue on a fresh install of Windows 11 / VS 2022 targeting . NET 4.8 (there's no 4.6.1 installed)

Unfortunately this bug kept coming and going so I ended up just giving up on using strongnamer altogether... we sign our files with an external key for that specific case.
We initially contemplated just creating a signed version of those packages but gave up on it eventually as it seems like way too much work to keep up with updates like that.