Share via


System.IO.FileNotFoundException: Could not load file or assembly 'System.Management.Automation’ Error during vNext deployment

Issue

Unable to deploy to a machine using vNext Release management template to a standard machine.
Error stack

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AggregateException: One or more errors occurred. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.PowershellExecutor.DisposeCurrentSession()
at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.RemoteDeploymentHelper.Dispose()
at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.DeploymentClient.<RunAsync>d__11.MoveNext()

--- End of stack trace from previous location where exception was thrown

Environment

· Release Management 2013.4 (applies to 2013.3 above) on Windows 2008 R2 OS or Windows 2012. Doesn’t apply to Windows Server 2012 R2. Install the pre-requisites (Windows Management Framework 4.0 and winRM configuration etc) as mentioned in this blog.

· TFS 2013.4 (applies to all version of TFS compatible with RM server)

Cause

I got this exception whenever I tried a release. This was irrespective of the OS of the deployment machine selected. The missing assembly is a part of Windows Management Framework. I checked and confirmed that on the 2008 R2 server I had installed the latest framework and on the 2012 R2 machine it comes pre-loaded.

After some searching and troubleshooting with logs I found that I had missed installing the Windows Management framework on the Release Management server. The load failure was on the Release Management server and not on the agent machines.

Resolution

I went ahead and installed both Windows Management Framework 3.0 and Windows Management Framework 4.0 on the RM server and this fixed my assembly load error. Beware of a restart at the end of installation (especially if the Release Management server is in production)!

Of course my PowerShell script failed on the first attempt- but at least the error was with my script and not with the environment.

 

Content created by – Venkata Narasimhan
Content reviewed by – Romit Gulati