Microsoft Expression Encoder and Selenium + TeamCity

387 Views Asked by At

I'm trying to record my Selenium tests execution with Microsoft Expression Encoder. I've found many answers about the problem I'm currently facing but none of them really solved it. So, I have a method that starts the video recording process. It goes as simple as

        scj = new ScreenCaptureJob();
        scj.OutputScreenCaptureFileName = logPath + "\\" + fileName + ".wmv";
        scj.ScreenCaptureVideoProfile.FrameRate = 25;
        scj.CaptureMouseCursor = true;
        scj.Start();

When I run it from Visual Studio 2015 it works perfectly fine. But when I run it from TeamCity in one of our build agents, I get the following message:

OneTimeSetUp: System.BadImageFormatException: Could not load file or assembly 
'Microsoft.Expression.Encoder, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. An attempt was made to load a program with an incorrect format

Now, for what I've read over some forums, this is related to my architecture selection. In TeamCity, the build step that compiles the code has the "Any CPU" platform selected whereas in Visual Studio, "Mixed Platforms" is selected.

I already tried setting everything to x86 architecture in TeamCity, force NUnit 3 to run as a 32-bits process and also changing my project's target archicteture. None of those solutions has worked. Does anyone have any idea of what else I could do?

1

There are 1 best solutions below

3
On

You probably installed Microsoft.Expression.Encoder from its corresponding NuGet package.

You are also most likely not keeping your packages in source control (as it should be).

For that reason, when TC checks out the code the node packages are missing which requires a build step using the NuGet Installer, which will restore your packages before TC tries to build the code.

Teamcity NuGet Installer