3

C# / Visual Studio:

Part of the installation of the WinSCP NuGet package includes adding WinSCP.exe to my project root. (While I'm not entirely happy with that location in my project, that's not my question). If I don't need to, I'd rather not have to include WinSCP.exe in my git repo - can I add this to the .ignore (as this will be added when NuGet packages are restored) or is it necessary to keep?

(summary - if I'm using WinSCP nuget package, can I safely tell git to ignore WinSCP.exe?)

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
jack
  • 303
  • 3
  • 12

2 Answers2

3

Unfortunately the WinSCP NuGet package, currently version 5.7.5, has the WinSCP.exe inside the Content directory. This means that NuGet will add the file to the project.

Files added directly to the project will not be restored by NuGet. NuGet restore will restore files in the packages directory but not files inside the project directory.

So you would need to add the file to version control or have some sort of pre-build step that downloads the NuGet package and extracts the file.

However if you are not using WinSCP.exe, and you are just using the WinSCP.dll then you can get away without having WinSCP.exe in source control however you would need to remove it from your project otherwise you will get a build error.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • 2
    I'm pretty sure the issue is that WinSCP.dll is calling WinSCP.exe to do its work, which is the problem. I think now that it is installed via my installation, I can move the .exe to a different location, still in my project. As long as it still builds to the same location, I think it's fine. – jack Oct 21 '15 at 19:38
  • Yes, I was not sure how WinSCP.dll was working. The NuGet package description suggested it was using WinSCP.exe. – Matt Ward Oct 21 '15 at 20:18
0

WinSCP 5.12 NuGet package supports PackageReference package management, which should resolve the problem.

PackageReference package management is supported by Visual Studio 2017.

Go to Tools > NuGet Package Manager > Package Manager Settings > Package Management. In Default package management format select PackageReference. Or check Allow format selection on first package install to allow per-project setting.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992