Keep WinSCP.EXE out of root folder when publishing ASP .NET package

Advertisement

cbsewell
Joined:
Posts:
5
Location:
Ontario

Keep WinSCP.EXE out of root folder when publishing ASP .NET package

I have installed the latest stable WinSCP NuGet package as part of an ASP .NET web server in Visual Studio 2022. When I publish my web site to a deploy package, WinSCP.EXE is copied to both the root folder and the /bin directory in the publish zip file. How do I keep it out of the root folder and just leave it in /bin?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,253
Location:
Prague, Czechia

Re: Keep WinSCP.EXE out of root folder when publishing ASP .NET package

How exactly do you create the "publish zip file"? I do not see that option in VS.

When I select publish to a "Folder", I get only one copy of winscp.exe – in the root. And there's no bin folder. Though I have VS 2019. Did something change?

Reply with quote

cbsewell
Joined:
Posts:
5
Location:
Ontario

Re: Keep WinSCP.EXE out of root folder when publishing ASP .NET package

Right click on project in project explorer and select 'Publish...'. The Publish Method I have chosen is 'Web Deploy Package' and the location of where that package should be created. After publishing, the location contains, among other things, the zip file that you can copy to your IIS server and install using Deploy->Import Application... in IIS Manager.

For some reason WinSCP.EXE is included in the root folder of the deploy package as well as the /bin folder. I'm not sure why. I can uncheck it when Importing, or even delete it from the zip file I suppose, but it shouldn't be there to start with.

I did mention this is an ASP .NET web site application, so a bin folder should be present.

Reply with quote

martin
Site Admin
martin avatar

Re: Keep WinSCP.EXE out of root folder when publishing ASP .NET package

I've tried that. And I still have only one copy of WinSCP.exe in the zip file. In:
Content\B_C\<project>\<project>\obj\Release\net5.0\PubTmp\Out\WinSCP.exe

Reply with quote

cbsewell
Joined:
Posts:
5
Location:
Ontario

Don't know what I am doing wrong:
Content/C_C/Users/<username>/Source/Repos/<git repository name>/<project name>/obj/Release - Production/Package/PackageTmp/WinSCP.EXE
and
Content/C_C/Users/<username>/Source/Repos/<git repository name>/<project name>/obj/Release - Production/Package/PackageTmp/bin/WinSCP.EXE
The first path contains all the ASPX pages, web.config, etc. The second path contains the compiled DLLs.

The WinSCP.targets file looks OK:
<Content Include="$(MSBuildThisFileDirectory)..\tools\WinSCP.exe">
  <Link>WinSCP.exe</Link>
  <Visible>false</Visible>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,253
Location:
Prague, Czechia

– I have installed VS 2022
– Started new "ASP.NET Core Web App" project, keeping all defaults (including .NET 6.0)
– Added WinSCP 5.19.5 NuGet package
– Added some dummy code to Program.cs that uses WinSCP.Session to make sure the WinSCP .NET assembly is linked in (probably not needed)
– Went to Publish > Web Server (IIS) > Web Deploy Package, clicked Publish

I got ZIP file with only one WinSCP.exe file in: Content\C_C\Users\martin\source\repos\WebApplication1\WebApplication1\obj\Release\net6.0\PubTmp\Out\

Where do we differ?

Reply with quote

cbsewell

It's a mystery. Anyway, when I go to import the package in IIS, I just uncheck that extra WinSCP.EXE so it doesn't end up in the web site root folder. The one in ~/bin is all I need.

Reply with quote

bob20220210
Guest

same issue here....

One thing I just noticed is that exe in the root folder is actually the previous version.

I have no idea where this is coming from.

Reply with quote

cbsewell

Well, it's all moot now since I replaced WinSCP with SSH.NET, which is a much better SSH solution. I wasn't the one picked WinSCP for SFTP upload/download in ASP.NET anyway; that was my predecessor.

Reply with quote

Advertisement

You can post new topics in this forum