I want to integrate the WinSCP .NET assembly into my Visual Studio 2015 executable project for SFTP operations. I've installed the assembly using the associated NuGet package, which includes WinSCPnet.dll and WinSCP.exe.
When I build my solution in release or debug configuration, these files are copied to the respective directory in the project's bin folder, as expected. But as soon as I click Start to run the startup project, WinSCP.exe simply vanishes, and an exception is eventually thrown confirming that WinSCP.exe does not exist in the expected directory.
Some potential solutions I discovered online suggested that an overzealous anti-virus program might be responsible for deleting the file, but the problem persists despite the exceptions I put into my AV, and using procmon to do some sluething I confirmed that msbuild.exe is the culprit that is deleting WinSCP.exe, and I don't know why.
If I run my solution standalone, this problem does not occur. It only happens when I try to run through Visual Studio, so I'm unable to use the debugger. I can workaround the problem by launching the WinSCP.exe GUI directly from the bin directory before I start up my solution so that msbuild.exe is unable to delete it (since it's in use), but this isn't a workable long-term solution.
Why would msbuild.exe be deleting WinSCP.exe from my build directory, and how do I stop it from doing that?
I got it working. For some reason, the WinSCP-net NuGet package wasn't being installed properly. I noticed that WinSCPnet was missing from the list of references in VS, but it's possible that something else failed during the install as well, and that was causing msbuild to want to kill the executable. I re-installed the WinSCP-net NuGet package (I'm pretty sure multiple times) and once I could see WinSCPnet in the list of references, this issue stopped happening.