Search code examples
powershelltfsreleaseneuronesb

How to add a file dependency to VisualStudioRemoteDeployer in remote PowerShell session running from TFS deployment task


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.


Solution

  • 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.