When trying to open an older solution in VS2017
there is an old Unit Test project that is giving me a problem when building.
I keep getting the following error when building this test project:
Could not load file or assembly 'file:///C:\Projects\MyProj\Test\DAL\UnitTestProj\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll' or one of its dependencies. The system cannot find the file specified.
I checked the project's references and it appears to be referencing Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
. Additionally there are no code errors. How could I ever figure out if it is one of its dependencies that it can't find?
Best Answer
I had a similar issue (with the additional message
The "BuildShadowTask" task failed unexpectedly
) with a project originally developed with VS2010, and got to spend the last few hours learning about yet another legacy facet of the build process.There is a good chance that you are dealing with private accessor files (
.accessor
), which were deprecated in VS2012 (original source). This was foreshadowed in an announcement from the VS2010 team that they were no longer working on these features.There is also a chance you're just dealing with erroneous refs to the wrong version of UnitTestFramework, but a NuGet restore should fix this. If not, see this GitHub thread for a possible fix (manually change the ref to the public folder), or move to the new MSTest.TestAdapter and MSTest.TestFramework packages (see MSDN support thread).
Solutions
A. Edit the unit test
.csproj
and change the itemInclude
references fromShadow
=>None
:<Shadow Include="Test References\namespace.accessor" />
to<None Include="Test References\namespace.accessor" />
B. Better yet, simply delete all the
.accessor
files from the unit test project'sTest References
folder.Ideally, you would also rewrite your unit tests to remove references to private methods, either by re-architecting to separate concerns or by changing properties to
internal
and using "friend" with theInternalsVisibleToAttribute
.For those who need to continue supporting testing of private methods for some reason, the same post provides the following suggestions to the logical question
"What is available for me then?"
:Further reading / sources that helped me piece this together: