Search code examples
visual-studionugetsetup-projectwinscpwinscp-net

When using WinSCPnet from NuGet, how can I get the executable into a custom output directory without a duplicate of the exe?


I'm using the WinSCPnet NuGet package in Visual Studio (.NET Windows Service, with a Setup Project) and have no issue with getting the WinSCPnet DLL into a bin directory in my custom output folder, but getting the WinSCP executable into the same directory is a problem. The closest I've gotten is by following the WinSCP guidance here, but this results in a copy of the executable in my root output directory AND another copy in my bin directory.

Already followed the directions here and referenced a related item here on Stack Overflow

My steps:

  1. Install WinSCPnet NuGet package
  2. Manually copy the WinSCP executable into my project and set the "Copy to Output Directory" parameter to "Copy if Newer"
  3. Set the write directory for the "Content" output in my setup project (Content placeholder is in the "bin" directory)
  4. Build setup project (and dependencies)
  5. Install the published MSI
  6. The WinSCP.exe executable appears in the root install directory as well as the "bin" directory.
  7. The installed service is twice the size it needs to be because of two instances of the WinSCP executable.

Can anyone offer guidance on this?


Solution

  • If I understand you correctly, you need a custom layout of the project. I still do not understand why. Why don't you take the files from the standard bin folder? Imo, the standard approach is to setup project take what's in the bin folder.

    Anyway, if you need a different layout, then do not use the NuGet package. Setup everything manually. See Using from Visual Studio section of Installing WinSCP .NET Assembly.