brutaldev / StrongNameSigner

Strong-name sign third party .NET assemblies without the source code.
https://brutaldev.com/post/net-assembly-strong-name-signer
Other
320 stars 68 forks source link

ASP core console signing problem #41

Closed Astimus closed 6 years ago

Astimus commented 7 years ago

Console signing doesn't work with asp .core applications. There are diffrenet errors in console: "Warning: Format of the executable (.exe) or library (.dll) is invalid" "Error: Operation is not valid due to the current state of the object"

brutaldev commented 7 years ago

The tool does not officially support signing .NET Core assemblies. PR is welcome if anyone wants to add this support.

carlescs commented 6 years ago

The thing is that using the GUI tool to sign them and adding them as reference works. It does not work using the nuget package. Just my two cents...

ffMathy commented 6 years ago

I really need this as well.

Currently just trying to sign a .NET Framework project that references a .NET Standard 1.6 class library, which I think is a very valid use case scenario and highly critical.

It could seem as if this could be resolved by just updating Mono.Cecil @brutaldev?

brutaldev commented 6 years ago

@ffMathy There is a branch for the latest version of mono-cecil, however, they have internal file locking issues which make the unit tests fail as well as large signing batches not being able to complete.

ffMathy commented 6 years ago

Alright. Is there an issue where progress on fixing that can be tracked or subscribed to?

paul-kiar commented 6 years ago

I'm getting this error on .Net Framework assemblies, it signs successfully but then outputs errors

Operation is not valid due to the current state of the object. at Mono.Cecil.ModuleDefinition.ProcessDebugHeader() at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader) at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters) at Mono.Cecil.ModuleReader.CreateModuleFrom(Image image, ReaderParameters parameters) at Mono.Cecil.ModuleDefinition.ReadModule(Stream stream, ReaderParameters parameters) at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) at Brutal.Dev.StrongNameSigner.SigningHelper.GetAssemblyInfo(String assemblyPath, String[] probingPaths) at Brutal.Dev.StrongNameSigner.AutomaticBuildTask.Execute()

brutaldev commented 6 years ago

@paul-kiar Update the the latest version.

paul-kiar commented 6 years ago

@brutaldev I'm using 2.1.4, the latest package on nuget, including the prereleases.

paul-kiar commented 6 years ago

The libraries I attempting to sign are 4.5.2 and 4.6.1

paul-kiar commented 6 years ago

Specifically IdentityModel.OidcClient version 2.6.0 from nuget.

paul-kiar commented 6 years ago

Turns out it's the project settings that were changed causing the error, I removed the project changes from my project and the errors stop. I then used console app and a pre-build event to sign the libraries. My project is being built in VS 2017 15.7.2 and the project target dotnet framework is 4.7.1.

paul-kiar commented 6 years ago

This is the code I removed from the project: `

This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. `
brutaldev commented 6 years ago

This could be attempted again using v2.2.0.

A similar issue was found in issue #47 which was corrected in the latest update.