brutaldev / StrongNameSigner

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

Writing mixed-mode assemblies is not supported #72

Closed kuhnboy closed 2 years ago

kuhnboy commented 2 years ago

Running into this error with mixed-mode assemblies with 3.1.0.

1> <<redacted>>\packages\Brutal.Dev.StrongNameSigner.3.1.0\build\Brutal.Dev.StrongNameSigner.targets(6,5): error : NotSupportedException: Writing mixed-mode assemblies is not supported
1> <<redacted>>\packages\Brutal.Dev.StrongNameSigner.3.1.0\build\Brutal.Dev.StrongNameSigner.targets(6,5): error :    at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
1> <<redacted>>\packages\Brutal.Dev.StrongNameSigner.3.1.0\build\Brutal.Dev.StrongNameSigner.targets(6,5): error :    at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
1> <<redacted>>\packages\Brutal.Dev.StrongNameSigner.3.1.0\build\Brutal.Dev.StrongNameSigner.targets(6,5): error :    at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
1> <<redacted>>\packages\Brutal.Dev.StrongNameSigner.3.1.0\build\Brutal.Dev.StrongNameSigner.targets(6,5): error :    at Brutal.Dev.StrongNameSigner.AssemblyInfo.Save(String assemblyPath, Byte[] keyPair)
1> <<redacted>>\packages\Brutal.Dev.StrongNameSigner.3.1.0\build\Brutal.Dev.StrongNameSigner.targets(6,5): error :    at Brutal.Dev.StrongNameSigner.SigningHelper.SignAssemblies(IEnumerable`1 assemblyInputOutputPaths, String keyFilePath, String keyFilePassword, String[] probingPaths)
1> <<redacted>>\packages\Brutal.Dev.StrongNameSigner.3.1.0\build\Brutal.Dev.StrongNameSigner.targets(6,5): error :    at Brutal.Dev.StrongNameSigner.AutomaticBuildTask.Execute()
1> <<redacted>>\packages\Brutal.Dev.StrongNameSigner.3.1.0\build\Brutal.Dev.StrongNameSigner.targets(6,5): error :

It is implied that this is fixed in 3.1.0 (https://github.com/brutaldev/StrongNameSigner/pull/67)

brutaldev commented 2 years ago

@kuhnboy Mono.Cecil is clearly not happy about the assembly you are using. You will need to provide me with the assembly you are trying to sign that causes that exception so I can reproduce and attempt to fix it.

The issue you refer to was the detection of mixed-mode and skipping them. Signing will not be supported for them, but if it can be detected they can be skipped and the error can be avoided. Whatever assembly you are trying to sign there clearly fails to identify as being mixed-mode so it attempts to sign it and fails.

kuhnboy commented 2 years ago

Ok thanks. So the correct answer is:

brutaldev commented 2 years ago

Fixed and deployed to NuGet: https://www.nuget.org/packages/Brutal.Dev.StrongNameSigner/3.1.1