MSBuildLocator icon indicating copy to clipboard operation
MSBuildLocator copied to clipboard

MSTestAdapter fails to discover tests

Open znakeeye opened this issue 5 years ago • 1 comments

I have referenced Build nuget packages as shown below. When I try to check in, my Build dependent unit tests fail on the build server.

I don't get it. Where does this 15.1.0.0 version come from? Why can't it load the assemblies?

MSTestAdapter failed to discover tests in class 'MyTests' of assembly 'Tests.dll'. Reason Could not load file or assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime">
  <Version>16.3.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Build.Engine" ExcludeAssets="runtime">
  <Version>16.3.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Build.Locator">
  <Version>1.2.6</Version>
</PackageReference>
<PackageReference Include="Microsoft.Build.Utilities.Core" ExcludeAssets="runtime">
  <Version>16.3.0</Version>
</PackageReference>

znakeeye avatar Dec 03 '19 18:12 znakeeye

I'm running into the same issue.

malkia avatar Mar 16 '20 17:03 malkia

15.1.0.0 is the correct version for modern MSBuild. How are you using MSBuildLocator? Was it succeeding in finding an installation with MSBuild? After the MSBuildLocator call, did you separate the MSBuild-related calls from the function that registers MSBuild?

Forgind avatar Mar 17 '23 22:03 Forgind

fixed this by adding the following

<PropertyGroup>
    <DisableMSBuildAssemblyCopyCheck>true</DisableMSBuildAssemblyCopyCheck>
</PropertyGroup>

<ItemGroup>
    <PackageReference Include="Microsoft.Build.Locator" Version="1.4.1" /> <!-- DO NOT UPDATE https://github.com/microsoft/MSBuildLocator/issues/210 -->
    <PackageReference Include="Microsoft.Build" Version="17.7.0" />
</ItemGroup>

to the csproj

hankovich avatar Aug 15 '23 14:08 hankovich

The issue seems to be not relevant anymore. Feel free to reopen if you still have any concerns.

YuliiaKovalova avatar Dec 14 '23 14:12 YuliiaKovalova