Skip to content

Delay-signed assemblies don't load on xunit.runner.visualstudio 3.0 #3130

@AArnott

Description

@AArnott

I've been successfully delay-signing my test assemblies and still running tests on them with xunit.runner.visualstudio 2.x for years, by simply having this file in my test project directory:

<configuration>
  <appSettings>
    <add key="xunit.shadowCopy" value="false"/>
  </appSettings>
</configuration>

But xunit.runner.visualstudio 3.0.x breaks this, causing the tests to fail:

[xUnit.net 00:00:01.41] Microsoft.VisualStudio.Sdk.TestFramework.Tests: Catastrophic failure: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.VisualStudio.Sdk.TestFramework.Tests, Version=17.11.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 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)
File name: 'Microsoft.VisualStudio.Sdk.TestFramework.Tests, Version=17.11.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'       
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Xunit.Sdk.ReflectionAssemblyInfo..ctor(String assemblyFileName) in /_/src/xunit.execution/Sdk/Reflection/ReflectionAssemblyInfo.cs:line 33   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Xunit.AppDomainManager_AppDomain.CreateObject[TObject](AssemblyName assemblyName, String typeName, Object[] args)
   at Xunit.Runner.v2.Xunit2..ctor(IMessageSink diagnosticMessageSink, AppDomainSupport appDomainSupport, ISourceInformationProvider sourceInformationProvider, IAssemblyInfo assemblyInfo, String assemblyFileName, String xunitExecutionAssemblyPath, String configFileName, Boolean shadowCopy, String shadowCopyFolder, Boolean verifyAssembliesOnDisk)
   at Xunit.Runner.v2.Xunit2.ForDiscoveryAndExecution(XunitProjectAssembly projectAssembly, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink, Boolean verifyAssembliesOnDisk)
   at Xunit.XunitFrontController.Create(XunitProjectAssembly projectAssembly, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink, ITestProcessLauncher testProcessLauncher)
   at Xunit.Runner.VisualStudio.VsTestRunner.<RunTestsInAssembly>d__33.MoveNext()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions