Build fails with missing file: System.Management.Automation.dll

The Problem

  • The Build breaks with the following message:

Exception Message: Could not load file or assembly ‘System.Management.Automation, PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The system cannot find the file specified. (type FileNotFoundException)

The Solution

The Cause

  • You might be using the Community TFS Build Extensions. These include the InvokePowerShellCommand activity, which has a dependency on this .DLL

–Neno

Build fails to find GraphCmd.exe (Layer Diagram Validation)

The Problem

  • The Build breaks with the following message:

Error message:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\ArchitectureTools\Microsoft.VisualStudio.TeamArchitect.LayerDesigner.targets (148): The "GraphCmd" task failed unexpectedly. System.InvalidOperationException: Cannot start process because a file name has not been provided.

The Solution

Add this xml snippet into all of your Modeling project (*.modelproj) files:
<PropertyGroup>
    <GraphCmdPath Condition="’$(GraphCmdPath)’==” and ‘$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\Architect@GraphCmdDir)’ != ”">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\Architect@GraphCmdDir)</GraphCmdPath>
</PropertyGroup>

–Neno

How to compile projects that reference Microsoft.Office.Interop assemblies with a build server

The Problem

A project that references Office interop assemblies (Microsoft.Office.Interop) fails to compile on TF Build (or VSO’s Elastic Build Service).

The error message might be similar to this one:

The type or namespace name ‘Office’ does not exist in the namespace ‘Microsoft’ (are you missing an assembly reference?)

The Solution (based on this forum post)

You want to check-in the interop assemblies.

  1. Create a “Lib” folder and add all relevant assemblies, like:
    • Microsoft.Office.Interop.Word.dll
    • Microsoft.Office.Interop.Excel.dll
    • Microsoft.Vbe.Interop.dll
    • OFFICE.DLL
  2. Removed the references to your Office interop assemblies and add references to the assemblies in your libs folder.

–Neno