Consider this scenario:
- You have installed Jenkins on a windows server
- You are building visual studio project using msbuild plugin in Jenkins
- 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:
- 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.
- 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.