.net5 (dotnet core) single-file bundle support

Advertisement

sckramer
Joined:
Posts:
3

.net5 (dotnet core) single-file bundle support

Using nuget package: 5.17.9
C:\temp>cdsutil -sftp -debug

Message:
CodeBase is not supported on assemblies loaded from a single-file bundle.

Type:
NotSupportedException

StackTrace:
   at System.Reflection.RuntimeAssembly.get_CodeBase()
   at WinSCP.Logger.DoGetAssemblyFilePath(Assembly assembly)
   at WinSCP.Logger.GetAssemblyFilePath()
   at WinSCP.ExeSessionProcess.GetAssemblyPath()
   at WinSCP.ExeSessionProcess.GetExecutablePath()
   at WinSCP.ExeSessionProcess..ctor(Session session, Boolean useXmlLog, String additionalArguments)
   at WinSCP.Session.Open(SessionOptions sessionOptions)
   at cdsutil.cdsSFTP.ListDirectory(String remoteDirectory)

Screen Shot 2020-12-04 at 1.26.58 AM.jpg

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
35,415
Location:
Prague, Czechia

Re: .net5 (dotnet core) single-file bundle support

Thanks for your report.

This issue has been added to the tracker:
https://winscp.net/tracker/1932

I'm sending you an email with a development version of WinSCP to the address you have used to register on this forum.

Reply with quote

sckramer
Joined:
Posts:
3

Thank you for working on this. I tried a few angles testing this as if it were in a nuget package with no luck, just a variety of errors including the original. Maybe create a test nuget package?

build command:
dotnet publish -c Release -r win-x64 --output bin/publish --self-contained=true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishTrimmed=true

Reply with quote

Advertisement

danelliott
Joined:
Posts:
1
Location:
Philadelphia, PA

NuGet & Package Request

Will this fix be released to NuGet soon? May I also get a copy of the package in the meantime?
I do see it will be packaged with 5.18.1.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
35,415
Location:
Prague, Czechia

Re: NuGet & Package Request

danelliott wrote:

Will this fix be released to NuGet soon? May I also get a copy of the package in the meantime?
I do see it will be packaged with 5.18.1.
Sent.

Reply with quote

Heiko
Joined:
Posts:
2

Need package with fix

Hi,
same issue to me. Will there be a new prerelease v5.18.1 on nuget.org?
May I also get a copy of the package in the meantime?

Thanks in advance.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
35,415
Location:
Prague, Czechia

Re: Need package with fix

Heiko wrote:

same issue to me. Will there be a new prerelease v5.18.1 on nuget.org?
May I also get a copy of the package in the meantime?
Sent.

Reply with quote

Heiko
Joined:
Posts:
2

Re: Need package with fix

Hi Martin,
many thanks for sending me.
And also for publishing a new beta on NuGet. That make my (our) live a bit easier :-)

Unfortunately it doesn't work with that yet. I still get the following error message if I set PublishSingleFile=true
WinSCP.SessionLocalException: The winscp.exe executable was not found at location of the assembly WinSCPnet (), nor the entry assembly Xxxxx (), nor in an installation path. You may use Session.ExecutablePath property to explicitly set path to winscp. exe.
I haven't had time to test if it works when I set ExecutablePath. I'll test it with that as soon as possible. It would be great if you could check that again, too.

Note: I use the following method for the correct localization of the appsettings.json (works for VS debug, publish as single file and not as single file):
private static string GetBasePath()
{
  //The following code configures the application to look at the directory
  //that the single-executable application was run from,
  //rather than the place that the binaries were extracted to.
  //
  //That does not work proper: 
  // Environment.CurrentDirectory or AppDomain.CurrentDomain.BaseDirectory
 
  using ProcessModule processModule = Process.GetCurrentProcess().MainModule;
  return Path.GetDirectoryName(processModule?.FileName);
}

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
35,415
Location:
Prague, Czechia

Re: Need package with fix

Heiko wrote:

Unfortunately it doesn't work with that yet. I still get the following error message if I set PublishSingleFile=true
WinSCP.SessionLocalException: The winscp.exe executable was not found at location of the assembly WinSCPnet (), nor the entry assembly Xxxxx (), nor in an installation path. You may use Session.ExecutablePath property to explicitly set path to winscp. exe.
I'm not sure what you expected here. WinSCP .NET assembly still requires separate WinSCP.exe file.
You may want to check: https://winscp.net/eng/docs/library_install#embed
Can you share steps to reproduce your project?

Reply with quote

martin
Site Admin
martin avatar

JamesJamesbo00978 wrote:

Hi, did you manage to get winscp to work with .net5? I have the same issue
Can you please elaborate? This thread is not really about .NET 5.

Reply with quote

JamesJamesbo00978
Joined:
Posts:
2
Location:
UK

Hi Martin,

Thanks for replying.

I have been trying to use WinSCP nuget bundled into my .net5 wpf app. Tried testing both the release and the beta but I keep getting the error what sckramer showed. I also tried to embed the binary and copy to temp directory and run it from there but no luck. Was wondering if you have a solution for this. I would like to continue using WinSCP for automated file uploads as it has lots of features I like. The heading of thee thread says ".net5 (dotnet core) single-file bundle support" so thought to try and reply to the post. I could create another post?

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum