Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appveyor (CI): Strong name signature verification error fails builds & blocks next version release #1340

Closed
stakx opened this issue Apr 30, 2023 · 5 comments

Comments

@stakx
Copy link
Contributor

stakx commented Apr 30, 2023

Something must have changed with build tools sometime in the last few months, we're not getting errors such as this one during Appveyor CI builds:

System.IO.FileLoadException : Could not load file or assembly 'Moq.Tests.FSharpTypes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)

Not sure what is going on there. Unfortunately, this fails the build, which in turn blocks PRs and also releasing a new version of Moq with the latest changes.

If anyone knows what is going wrong here, help is appreciated.

@david-kalbermatten
Copy link
Contributor

From my limited time testing, I can reproduce the issue on my Windows machine as well, running this command in the project root:

dotnet test --configuration Release .\tests\Moq.Tests\Moq.Tests.csproj

It produces the same errors as AppVeyor. Removing the Test target in the AppVoyer config allows it to build at the cost of the tests not running. Ultimately it's up to you how you want to proceed.

https://ci.appveyor.com/project/david-kalbermatten/moq4/builds/47263465

@david-kalbermatten
Copy link
Contributor

More specifically the DLL produced by the build cannot be validated by sn.exe

."C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7 Tools\x64\sn.exe" -vf .\tests\Moq.Tests.FSharpTypes\bin\Release\net472\Moq.Tests.FSharpTypes.dll

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Failed to verify assembly -- Strong name validation failed.

I tried a few things but couldn't figure out why it fails.

@david-kalbermatten
Copy link
Contributor

Ok, I may have figured out a way around it. You can resign the Assembly before running the tests, by calling the sn.exe like so:

."C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7 Tools\x64\sn.exe" -R .\tests\Moq.Tests\bin\Release\net472\Moq.Tests.FSharpTypes.dll .\Moq.snk

Now when running the tests with the release configuration without rebuilding, it doesn't produce the errors anymore.

dotnet test --no-build --configuration Release .\tests\Moq.Tests\Moq.Tests.csproj

How this can be achieved on AppVeyor, I cannot say. I guess the single call of msbuild will have to be split up so you can call sn.exe before running the tests

@david-kalbermatten
Copy link
Contributor

Aight, I think I managed to fix it for the time being. Please have a look at my PR #1346

@kzu
Copy link
Contributor

kzu commented Jun 30, 2023

Merged! Thanks @david-kalbermatten !

@kzu kzu closed this as completed Jun 30, 2023
@kzu kzu unpinned this issue Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants