we have some tests which execute a powershell script on some files to ensure that the script processes the files correctly.
This is an example:
[TestMethod]
[DeploymentItem(@"BuildScripts\CheckForFxCop.ps1")]
[DeploymentItem(@"TestData\TestWithIncorrectFxCop\TestWithIncorrectFxCop.csprojext", "TestWithIncorrectFxCop")]
public void WhenFxCopHasWrongValueFails()
{
string projectFileToTest = Path.Combine(Directory.GetCurrentDirectory(), "TestWithIncorrectFxCop", "TestWithIncorrectFxCop.csprojext");
string scriptFileToExecute = Path.Combine(Directory.GetCurrentDirectory(), "CheckForFxCop.ps1");
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "powershell.exe",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = false
};
startInfo.Arguments = string.Format(@"& '{0}' '{1}' csprojext", scriptFileToExecute, projectFileToTest);
var process = new Process { StartInfo = startInfo };
process.Start();
... assert some stuff...
}
These tests have been running for the last 9 months on the build server.
We installed powershell 3 on one server recently and this made all of these tests fail with:
System.ComponentModel.Win32Exception: The system cannot find the file specified
thrown at the process.Start()
line.
We stopped tests running on this server temporarily and just used the servers which don't have powershell 3.0 installed.
We have recently installed AzureSDK 2.1 on the other build servers and we are now getting the same issue on all the servers.
If we log on to the build machine as the build agent user and manually start powershell and run the commands that the test is running it seems to succeed ok.
Does anyone have any idea what might be causing these tests to fail now? Or have any ideas about how we might be able to diagnose the issue?
So it looks like the issue was related to
we had some other tests which had this set to true that were succeeding and something about running them as the build agent account (or the fact that the build agent runs a s a service more likely) meant that they were failing, not sure why the file not found was the error though.
Anyway problem solved I think.