BuildShadowTask "Could not load file or assembly"
My Solution Built fine last Friday.
Today I fired it up and I am getting this error message:
Could not load file or assembly 'MyApplication, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
This is failing in my Smart Device Unit Test project.
I have Googled around for this. And while others have had my problem, I can't seem to find a fix that works.
When I double click on the error it takes me to Microsoft.TeamTest.targets. This is the target in question:
<Target Name="ResolveTestReferences" Condition="'@(Shadow)'!=''">
<BuildShadowTask
CurrentResolvedReferences="@(Referen开发者_Python百科cePath)"
CurrentCopyLocalFiles="@(ReferenceCopyLocalPaths)"
Shadows="@(Shadow)"
ProjectPath="$(ProjectDir)"
IntermediatePath="$(IntermediateOutputPath)"
SignAssembly="$(SignAssembly)"
KeyFile="$(AssemblyOriginatorKeyFile)"
DelaySign="$(DelaySign)">
<Output TaskParameter="FixedUpReferences" ItemName="ReferencePath"/>
<Output TaskParameter="NewCopyLocalAssemblies" ItemName="ReferenceCopyLocalPaths"/>
</BuildShadowTask>
</Target>
If I just build my actual project (not the test project) then it works fine.
Any Ideas?
Found the solution.
The problem is Release mode, project references and the copy local flag. In Release the accessor assembly seems to be built using a different mechanism which has a flaw.
The flaw must be a bad assumption. By default a project reference has copy local flag set to true. This means no XML node is written to the unit test project file for the project reference. If I force the XML node to be written to the project file by flipping the flag to false then to true the issue is resolved.
Another terrible hack job by MS, no wonder this is being deprecated in 2012.
Add a dependency on your unit test project to your actual product project in the solution properties window on the "Project Dependencies" dialogue.
That should ensure the actual product gets built before the unit test project if it isn't built yet already.
精彩评论