{"action":"created","issue":{"url":"https://api.github.com/repos/Particular/NServiceBus.Testing/issues/22","labels_url":"https://api.github.com/repos/Particular/NServiceBus.Testing/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/Particular/NServiceBus.Testing/issues/22/comments","events_url":"https://api.github.com/repos/Particular/NServiceBus.Testing/issues/22/events","html_url":"https://github.com/Particular/NServiceBus.Testing/issues/22","id":58042910,"number":22,"title":"Assembly scanner and XUnit 2.0 does not work well together","user":{"login":"janovesk","id":396480,"avatar_url":"https://avatars.githubusercontent.com/u/396480?v=3","gravatar_id":"","url":"https://api.github.com/users/janovesk","html_url":"https://github.com/janovesk","followers_url":"https://api.github.com/users/janovesk/followers","following_url":"https://api.github.com/users/janovesk/following{/other_user}","gists_url":"https://api.github.com/users/janovesk/gists{/gist_id}","starred_url":"https://api.github.com/users/janovesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janovesk/subscriptions","organizations_url":"https://api.github.com/users/janovesk/orgs","repos_url":"https://api.github.com/users/janovesk/repos","events_url":"https://api.github.com/users/janovesk/events{/privacy}","received_events_url":"https://api.github.com/users/janovesk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-18T09:08:56Z","updated_at":"2015-02-18T14:50:57Z","closed_at":null,"body":"From https://groups.google.com/forum/#!topic/particularsoftware/Q7O30xPUUko\r\n\r\nNServiceBus.Testing\r\nVersion 4.7.5\r\n\r\nXUnit 2.0 has moved the VS runner support to NuGet (as opposed to an extension).\r\n\r\nI have a suite of tests that do Test.Initialize() and the scan now includes xunit.runner.visualstudio.testadapter.dll (as the NuGet package configures this to be copied to the output folder). The scan then looks (via dependency?) for Microsoft.VisualStudio.TestPlatform.ObjectModel which isn't found and so get a FileNotFoundException. \r\n\r\nI can just change to Test.Initialize(AllAssemblies.Except(\"xunit.runner.visualstudio.testadapter\")) but I'm wondering if there is some other way I can do this via config for example? Or even add xunit to a known list of excludes for the Test.Initialize scan?\r\n\r\nThanks\r\nSimon\r\n\r\n/*\r\nEmail: simon.m.fox@gmail.com\r\nTwitter: @simonmfox\r\n*/"},"comment":{"url":"https://api.github.com/repos/Particular/NServiceBus.Testing/issues/comments/74875840","html_url":"https://github.com/Particular/NServiceBus.Testing/issues/22#issuecomment-74875840","issue_url":"https://api.github.com/repos/Particular/NServiceBus.Testing/issues/22","id":74875840,"user":{"login":"danielmarbach","id":174258,"avatar_url":"https://avatars.githubusercontent.com/u/174258?v=3","gravatar_id":"","url":"https://api.github.com/users/danielmarbach","html_url":"https://github.com/danielmarbach","followers_url":"https://api.github.com/users/danielmarbach/followers","following_url":"https://api.github.com/users/danielmarbach/following{/other_user}","gists_url":"https://api.github.com/users/danielmarbach/gists{/gist_id}","starred_url":"https://api.github.com/users/danielmarbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielmarbach/subscriptions","organizations_url":"https://api.github.com/users/danielmarbach/orgs","repos_url":"https://api.github.com/users/danielmarbach/repos","events_url":"https://api.github.com/users/danielmarbach/events{/privacy}","received_events_url":"https://api.github.com/users/danielmarbach/received_events","type":"User","site_admin":false},"created_at":"2015-02-18T14:50:57Z","updated_at":"2015-02-18T14:50:57Z","body":"I had a deeper look into this. Indeed I can reproduce the same exception.\r\n\r\n````\r\nTest Name:\tXUnitReproBug.Class1.Fact\r\nTest FullName:\tXUnitReproBug.Class1.Fact\r\nTest Source:\tc:\\particular\\NServiceBus.Testing\\src\\XUnitReproBug\\Class1.cs : line 10\r\nTest Outcome:\tFailed\r\nTest Duration:\t0:00:00.123\r\n\r\nResult Message:\t\r\nSystem.Exception : Could not enumerate all types for 'C:\\particular\\NServiceBus.Testing\\src\\XUnitReproBug\\bin\\Debug\\xunit.runner.visualstudio.testadapter.dll'.\r\nExceptions:\r\nSystem.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.\r\nFile name: 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.\r\nFile name: 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'\r\n\r\nWRN: Assembly binding logging is turned OFF.\r\nTo enable assembly bind failure logging, set the registry value [HKLM\\Software\\Microsoft\\Fusion!EnableLog] (DWORD) to 1.\r\nNote: There is some performance penalty associated with assembly bind failure logging.\r\nTo turn this feature off, remove the registry value [HKLM\\Software\\Microsoft\\Fusion!EnableLog].\r\nResult StackTrace:\t\r\nat NServiceBus.Hosting.Helpers.AssemblyScanner.ScanAssembly(String assemblyPath, AssemblyScannerResults results) in c:\\particular\\NServiceBus\\src\\NServiceBus.Core\\Hosting\\Helpers\\AssemblyScanner.cs:line 165\r\n   at NServiceBus.Hosting.Helpers.AssemblyScanner.GetScannableAssemblies() in c:\\particular\\NServiceBus\\src\\NServiceBus.Core\\Hosting\\Helpers\\AssemblyScanner.cs:line 65\r\n   at NServiceBus.BusConfiguration.GetAssembliesInDirectory(String path, String[] assembliesToSkip) in c:\\particular\\NServiceBus\\src\\NServiceBus.Core\\BusConfiguration.cs:line 241\r\n   at NServiceBus.BusConfiguration.ScanAssembliesInDirectory(String probeDirectory) in c:\\particular\\NServiceBus\\src\\NServiceBus.Core\\BusConfiguration.cs:line 90\r\n   at NServiceBus.BusConfiguration.BuildConfiguration() in c:\\particular\\NServiceBus\\src\\NServiceBus.Core\\BusConfiguration.cs:line 182\r\n   at NServiceBus.Bus.Create(BusConfiguration configuration) in c:\\particular\\NServiceBus\\src\\NServiceBus.Core\\Bus.cs:line 17\r\n   at NServiceBus.Testing.Test.Initialize(Action`1 customisations) in c:\\particular\\NServiceBus.Testing\\src\\NServiceBus.Testing\\Test.cs:line 60\r\n   at XUnitReproBug.Class1.Fact() in c:\\particular\\NServiceBus.Testing\\src\\XUnitReproBug\\Class1.cs:line 11\r\n```\r\n\r\nI would argue it is not really a bug from the perspective of the library and also the core. By default all assemblies are scanned in the current directory. If an assembly cannot be loaded because a reference is missing then the scanning blows up and you have to manually exclude that library with `AllAssemblies.Except()`. \r\n\r\nSo the workaround for the user is to do the following:\r\n\r\n## Workaround\r\n   Test.Initialize(c =>c.AssembliesToScan(AllAssemblies.Except(\"xunit.runner.visualstudio.testadapter\")));\r\n\r\nNow here comes the caveat. As soon as xunit2 is stable everyone using xunit2 in combination with the VS adapter will need to exclude the `\"xunit.runner.visualstudio.testadapter` from the scanning. I have no idea how many users are affected. \r\n\r\nHere comes another catch:\r\n\r\nI wanted to add a default exclusion. The issue is that exclusions are currently managed in the core. I think we don't want to upgrade/hotfix the core everytime we need to exclude something from the scanning. So ideally it should be possible to provide default exclusions in the Testing library. The issues is that currently we cannot do it properly. We expose the `BusConfiguration` in the lambda in the Initialize method BUT I cannot provide a default `AllAssemblies.Except` to `AssembliesToScan` because as soon as the user itself calls `AssembliesToScan` he overwrites all the defaults. The API of `AssembliesToScan` isn't intended to be called multiple times. \r\n\r\nWhat is the best way to move this forward?\r\n\r\n// cc @andreasohlund @janovesk @johnsimons "}}