The “CompileWorkflowTask” task failed unexpectedly – Jenkins build failure

Consider this scenario:

  1. You have installed Jenkins on a windows server
  2. You are building visual studio project using msbuild plugin in Jenkins
  3. Your build keeps failing with below message:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5): 
error MSB4018: The "CompileWorkflowTask" task failed unexpectedly. 
[D:\TFS_WS_DEV\Source\ALERT.Process.Workflows\ALERT.Process.Workflows.csproj]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5): 
error MSB4018: System.IO.DirectoryNotFoundException: Could not find a part of the 
path 'C:\Windows\system32\config\systemprofile\AppData\Local\Temp\it1lwybv.tmp'. 
[D:\TFS_WS_DEV\Source\ALERT.Process.Workflows\ALERT.Process.Workflows.csproj]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5): 
error MSB4018: at System.IO.__Error.WinIOError(Int32 errorCode, 
String maybeFullPath) 
[D:\TFS_WS_DEV\Source\ALERT.Process.Workflows\ALERT.Process.Workflows.csproj]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5): 
error MSB4018: at System.IO.FileStream.Init(String path, FileMode mode, 
FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, 
Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)

There are two reasons this could happen:

  1. The path mentioned C:\Windows\system32\config\systemprofile\AppData\Local\Temp could actually does not exist. You can create the path using md or new-item cmdlet.
  2. The service account under which Jenkins is running does not have access to the path.

For Visual Studio projects, Jenkins will fail to build the project if running as service. This problem is caused by Jenkins running under Local System Account (used for Windows Services). To fix this problem, edit service details and set “Log on” details to a different local administrative user.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s