Reason:Unable to find assembly
See original GitHub issueDescription
I have a solution with a mix of .Net Framework 3.5, 4.6.2 and 4.7.2 (it really needs to be updated to 4.8, but I don’t have authorization to spend time on that right now).
I updated the MSTest.TestAdapter and MSTest.TestFramework from 1.4 to 2.2.4 and now the tests are showing in the Test Explorer, but they aren’t run. I was hoping to update just enough and now I’ve lost a lot of time trying different things.
I see this [MSTest][Discovery][C:\chr\git\mySolution\Tests\bin\Debug\net472\MyTests.dll] Failed to discover tests from assembly C:\chr\git\mySolution\Tests\bin\Debug\net472\MyTests.dll. Reason:Unable to find assembly ‘MyNet462.Data, Version=0.0.1.0, Culture=neutral, PublicKeyToken=ba37446064e06eb0’. in the Output > Tests. (I’ve changed the names).
Interesting enough, the tests run in our build with
- task: VSTest@2 displayName: ‘Run Unit Tests’ inputs: testAssemblyVer2: ‘**\MyTests.dll’ searchFolder: ‘$(Build.BinariesDirectory)’ testFiltercriteria: ‘TestCategory!=Integration’ runOnlyImpactedTests: false runInParallel: true codeCoverageEnabled: false platform: ‘$(BuildPlatform)’ configuration: ‘$(BuildConfiguration)’
Steps to reproduce
I created a new project with a mix of .Net 4.7.2 for the test project and a .Net 4.5.2 class library (MyNet452.Data.dll above it 4.6.2) but I couldn’t reproduce it there. It works great.
I deleted all but a simple test from my real project and the test ran. Once I added in the tests that had usings to the dll referenced, they stopped running.
I attempted upgrading to a .Net Core csproj and target net472, but have the same problem. This is my test project .csproj that works in my test sln, but not in my real sln.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.3" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.4" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.4" />
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Net.Http" Version="4.3.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OtherWeb.csproj" /> <-- this one references the other one and is 4.5.2 -->
<ProjectReference Include="..\AnotherClassLibrary.Common.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Web" />
</ItemGroup>
</Project>
An experiment to upgrade all to .Net 4.6.2 failed as I couldn’t get it to build and ran out of time.
Expected behavior
I need to be able to run the tests in VS.
I know this is a hard one. Maybe the answer is to upgrade everything, but I’d appreciate any pointers or suggestions
Is there a way to get more logs out of MSTest of why it can’t find my dll? I can’t find anything searching about “Reason: Unable to find assembly”. It’s probably due to the MyNet452.Data.dll referencing another project or nuget package or system assembly.
Environment
I’m in Windows 10, trying to run the tests from VS 2019 16.11.0 Preview 1.0 and VS 2019.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
you got me thinking. I went back to the original, updated to 2.0.0 and it worked. Then I updated to 2.2.4 and it doesn’t run in VS.
I went back to 2.1.0 => that works 2.2.1 brought in more libraries and only half my tests ran. I found the breaking point!
For now, I’m going to stick with 2.1.0 until we update all of projects.
Thank you @HgDorn! We’ll wait for your repro.