0

I am using TFS deployment task "PowerShell on Remote Machines". It runs a PowerShell script that I have previously copied to the target machine. The PowerShell script calls a cmdlet that has a dependency on an .exe. I get the following error when executing the script:

System.IO.FileNotFoundException: C:\Windows\DtlDownloads\VisualStudioRemoteDeployer3be2a227-e8d4-4e1f-b155-d1a53666793b\NeuronExplorer.exe

I cannot figure out how to actually get the NeuronExplorer.exe into that transient directory to be available for execution.

I have tried GACing it. It GACs successfully, but I get the same error.

I have tried adding the path to the PATH environment variable, also resulting in the same error.

I have been successful if I copy the NeuronExplorer.exe into the transient folder but I have to be very fast to actually make it work. There MUST be a way to get this file available in the remote context.

Aaron Palmer
  • 8,912
  • 9
  • 48
  • 77

2 Answers2

0

The easiest workaround here would be to invoke the executable via the full, explicit path.

Also, you didn't specify if you changed the PATH environment variable at the machine level, but if you did, you most likely need to restart the agent on that machine for the changes to be reflected in the agent process.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
0

The way I ended up solving this was to copy the .exe into my System.AppDomain.CurrentDomain.BaseDirectory prior to calling any API code that depends on the .exe.

let fileName = (FileInfo pathToExe).Name
let targetFile = sprintf "%s\\%s" System.AppDomain.CurrentDomain.BaseDirectory fileName
File.Copy(pathToExe, targetFile, true)

I could possible accomplish the same thing by using System.AppDomain.CurrentDirectory.Load(assemblyBytes), but the File.Copy works for me.

Hopefully this helps someone else not have to struggle with this particular issue.

Aaron Palmer
  • 8,912
  • 9
  • 48
  • 77