I have a legacy .NET Wins form application using .NET 4.0. I created a new test project that takes advantage of Microsoft Fakes and add this project to the solution. I am able to compile and run the units test locally.
I created a TFS Build Process Template based off the Default Template. We are using TFS 2012. I have a successful build processwithout the Fakes Unit Test project in the solution. Here are the errors I am seeing from the TFS build machine when the Fakes Unit Test project is part of the solution:
View Summary
1 error(s), 0 warning(s)
<dir><dir><dir>
Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException)Exception
Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Rethrow Compilation Exception
<dir><dir>Initial Property Values
Exception = Microsoft.TeamFoundation.Build.Workflow.Activities.BuildProcessTerminateException: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. at System.Activities.Statements.Throw.Execute(CodeActivityContext
context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor
executor, BookmarkManager bookmarkManager, Location resultLocation)
Final Property Values
Exception = Microsoft.TeamFoundation.Build.Workflow.Activities.BuildProcessTerminateException: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. at System.Activities.Statements.Throw.Execute(CodeActivityContext
context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor
executor, BookmarkManager bookmarkManager, Location resultLocation)
Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error
in above messages. (type BuildProcessTerminateException)Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance,
ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
<dir></dir>
<dir><dir></dir></dir>
<dir></dir><dir></dir></dir></dir>
</dir>
Diagnostics Log
fakes (TaskId:342)
code generation (TaskId:342)
stubs generation (TaskId:342)
stubs : Cannot generate stub for My.MyApplication: type is not visible to exported or assembly(CHRobinson.GFS.DTOs.Fakes).
(TaskId:342)
stubs : Cannot generate stub for My.MyComputer: type is not visible to exported or assembly(CHRobinson.GFS.DTOs.Fakes).
(TaskId:342)
stubs : Cannot generate stub for My.MyProject: type is sealed. (TaskId:342)
stubs : Cannot generate stub for CHRobinson.GFS.DTOs.Audit.AuditType: type is a value type. (TaskId:342)
stubs : Cannot generate stub for CHRobinson.GFS.DTOs.AwbStockingProgram.UpdateStockingNumberLoadNumReturnCode:
type is a value type. (TaskId:342)
...
stubs : Cannot generate stub for VB$AnonymousType_30`3: type is sealed. (TaskId:342)
stubs : Cannot generate stub for VB$AnonymousType_31`3: type is sealed. (TaskId:342)
stubs : Cannot generate stub for VB$AnonymousType_32`2: type is sealed. (TaskId:342)
shims generation (TaskId:342)
shims : Cannot generate shim for My.MyApplication: type is not visible to exported or assembly(CHRobinson.GFS.DTOs.Fakes).
(TaskId:342)
shims : Cannot generate shim for My.MyComputer: type is not visible to exported or assembly(CHRobinson.GFS.DTOs.Fakes).
(TaskId:342)
shims : Cannot generate shim for My.MyProject: type is not visible to exported or assembly(CHRobinson.GFS.DTOs.Fakes).
(TaskId:342)
shims : Cannot generate shim for CHRobinson.GFS.DTOs.Audit.AuditType: type is an enum. (TaskId:342)
shims : Cannot generate shim for CHRobinson.GFS.DTOs.AwbStockingProgram.UpdateStockingNumberLoadNumReturnCode:
type is an enum. (TaskId:342)
...
compiling (TaskId:342)
f -> E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\obj\Debug\Fakes\chrgfsf\b\CHRobinson.GFS.Facade.Fakes.dll
(TaskId:342)
(TaskId:342)
(TaskId:342)
fakes generator 0 errors, 102 warnings (TaskId:342)
4:end> Fakes\CHRobinson.GFS.Facade.fakes Success (0 - 0x0) (TaskId:342)
(TaskId:342)
5:start> Fakes\GFS.Module.fakes (TaskId:342)
Microsoft Fakes v11.0.60315.1 - .NET v4.0.30319 (TaskId:342)
Copyright (c) Microsoft Corporation 2007-2010. All rights reserved. (TaskId:342)
(TaskId:342)
fakes (TaskId:342)
code : assembly E:\Builds\13\Global Forwarding\GFS UI - Dev Build\bin\GFS.Module.dll failed to load properly (TaskId:342)
fakes generator 1 errors, 0 warnings (TaskId:342)
5:end> Fakes\GFS.Module.fakes error while loading the assembly (-1005 - 0xfffffc13) (TaskId:342)
(TaskId:342)
"C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Fakes\fakes.exe" @"E:\Builds\13\Global Forwarding\GFS UI - Dev
Build\src\GFS\GFSUnitTestsV2\obj\Debug\Fakes\gfsm\f.args" -- Success (0 - 0x0) (TaskId:342)
Microsoft Fakes v11.0.60315.1 - .NET v4.0.30319 (TaskId:342)
Copyright (c) Microsoft Corporation 2007-2010. All rights reserved. (TaskId:342)
(TaskId:342)
fakes (TaskId:342)
code : assembly E:\Builds\13\Global Forwarding\GFS UI - Dev Build\bin\GFS.Module.dll failed to load properly (TaskId:342)
fakes generator 1 errors, 0 warnings (TaskId:342)
(TaskId:342)
(TaskId:342)
(TaskId:342)
(TaskId:342)
Fakes compilation FAILED - 57.0737516220637s (TaskId:342)
result: unexpected exception occured (-1002 - 0xfffffc16) (TaskId:342)
Fakes assemblies: (TaskId:342)
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\FakesAssemblies\CHRobinson.GFS.DTOs.Fakes.dll (TaskId:342)
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\FakesAssemblies\CHRobinson.GFS.DTOs.Fakes.fakesconfig (TaskId:342)
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\FakesAssemblies\CHRobinson.GFS.Facade.Fakes.dll (TaskId:342)
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\FakesAssemblies\CHRobinson.GFS.Facade.Fakes.fakesconfig (TaskId:342)
Done executing task "GenerateFakes" -- FAILED. (TaskId:342)
06:45:47.414 14>Done building target "BuildFakesAssemblies" in project "GFSUnitTestsV2.vbproj" -- FAILED.: (TargetId:515)
...
Fake message (from navigating to Build Agent .\src\GFS\GFSUnitTestsV2\FakeAssemblies\)
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\Fakes\CHRobinson.GFS.DTOs.fakes : warning : Cannot generate stub for My.MyApplication: type is not visible to exported or assembly(CHRobinson.GFS.DTOs.Fakes).
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\Fakes\CHRobinson.GFS.DTOs.fakes : warning : Cannot generate stub for My.MyComputer: type is not visible to exported or assembly(CHRobinson.GFS.DTOs.Fakes).
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\Fakes\CHRobinson.GFS.DTOs.fakes : warning : Cannot generate stub for My.MyProject: type is sealed.
...
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\Fakes\CHRobinson.GFS.DTOs.fakes : warning : Cannot generate shim for My.MyApplication: type is not visible to exported or assembly(CHRobinson.GFS.DTOs.Fakes).
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\Fakes\CHRobinson.GFS.DTOs.fakes : warning : Cannot generate shim for My.MyComputer: type is not visible to exported or assembly(CHRobinson.GFS.DTOs.Fakes).
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\Fakes\CHRobinson.GFS.DTOs.fakes : warning : Cannot generate shim for My.MyProject: type is not visible to exported or assembly(CHRobinson.GFS.DTOs.Fakes).
...
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\Fakes\CHRobinson.GFS.DTOs.fakes : warning : Cannot generate shim for VB$AnonymousType_0`2: type is not supported because of internal limitations.
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\Fakes\CHRobinson.GFS.DTOs.fakes : warning : Cannot generate shim for VB$AnonymousType_1`2: type is not supported because of internal limitations.
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\Fakes\CHRobinson.GFS.DTOs.fakes : warning : Cannot generate shim for VB$AnonymousType_2`4: type is not supported because of internal limitations.
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\Fakes\CHRobinson.GFS.DTOs.fakes : warning : Cannot generate shim for VB$AnonymousType_3`2: type is not supported because of internal limitations.
E:\Builds\13\Global Forwarding\GFS UI - Dev Build\src\GFS\GFSUnitTestsV2\Fakes\CHRobinson.GFS.DTOs.fakes : warning : Cannot generate shim for VB$AnonymousType_4`4: type is not supported because of internal limitations.
Additional Information
We are Shim/Stub three different assemblies. We see three folders structures for the fakes under .\src\GFS\GFSUnitTestsV2\obj\Debug\Fakes\. We see success for two of the three fakes. (We are measuring success with seeing the f.csproj and supporting files and two folders.) So there is some good news here. It is just I am not sure what is going on with the third fake and need to discuss it with others.
Summary
We have a successful build process on a TFS 2012 Build Agent until we add a unit test project that uses Microsoft Fakes. The solution builds on local developer machine. We are seeing in the log files that the Build Agent is not able to create the Fakes artifacts needed to run the unit tests. I do not have access to the build server/agent and therefore cannot try to compile the solution on the build server/agent (it is not an option I am ready to ask for yet).
We are not sure what our next steps are to resolve this on the build machine since my internet search results are not finding others with the same issue (perhaps I am not using good enough search terms). Please advise.