Giter Site home page Giter Site logo

Support for dotnet? about docker-lambda HOT 19 CLOSED

lambci avatar lambci commented on July 24, 2024 2
Support for dotnet?

from docker-lambda.

Comments (19)

mhart avatar mhart commented on July 24, 2024 7

Unfortunately this is a lot harder than the other languages, because replacing a single class in a .NET DLL is virtually impossible without having the original source.

I'm waiting on some support from AWS for this – I'll let you know when they get back to me

from docker-lambda.

mhart avatar mhart commented on July 24, 2024 4

Oh yeah, forgot we also had an issue open. .NET Core 2.0 is now supported!

I'm going to close this out. If there's really a lot of ppl asking for .NET Core 1.0 support, I could look at adding that, but I feel like it's pretty low priority now that 2.0 is out.

from docker-lambda.

joaoasrosa avatar joaoasrosa commented on July 24, 2024

Hi @mhart,

Any updates on this?
Let me know if I can help.

Cheers

from docker-lambda.

mhart avatar mhart commented on July 24, 2024

@joaoasrosa sure! How much do you know about disassembling and reassembling .NET DLLs? If you can replicate the same way I do it in Java, that'd be a huge help: https://github.com/lambci/docker-lambda/blob/master/java8/run/lambda-runtime-mock/build.sh#L7-L14

from docker-lambda.

jason-riddle avatar jason-riddle commented on July 24, 2024

@mhart Is there a dotnet.tgz file we can play around with in order to test dissembling and reassembling?

from docker-lambda.

jason-riddle avatar jason-riddle commented on July 24, 2024

Actually it looks like #68 is attempting to address this issue.

from docker-lambda.

joaoasrosa avatar joaoasrosa commented on July 24, 2024

@mhart and @jason-riddle if you do not mind I can take a look to #68 and try from there.
Also, from your work in Java, we can try ILMerge. I need to invest some time in research since I do not know if they support it for dotnet core.

from docker-lambda.

romanlum avatar romanlum commented on July 24, 2024

The key diffrence between the .NET and the Java implementation ist that the .NET runtime is bootstraped from a NATIVE binary using native memory and native libraries...
That`s why i replaced the whole bootstrap in #68

from docker-lambda.

mhart avatar mhart commented on July 24, 2024

@romanlum it's actually still a compiled .NET binary though, and the libraries are .NET DLLs, except for the library that speaks to the AWS Lambda management layer, but that's the same with Java – that also uses a native library for that functionality, which is the only part I mock out.

Ideally the only part that is mocked out is just the part that communicates with the Lambda management layer – so that all of the rest of the code has the same behavior as it does on Lambda itself (eg, changing the way things are logged, or redirecting stdout or whatever).

from docker-lambda.

romanlum avatar romanlum commented on July 24, 2024

I don't think that the file /var/runtime/awslambda (which is the original entrypoint) is a compiled .net application.
It is a native application bootstraping the .net environment (calling /var/lang/bin/dotnet)

from docker-lambda.

romanlum avatar romanlum commented on July 24, 2024

Unfortunately we cannot use the original bootstrap.dll because there is a bug in the entrypoint which prevents us from replacing the lambda runtime as you did in java.

  if (!(str == "--lambda-runtime-override-assembly"))
          {
            if (!(str == "--lambda-runtime-override-type"))
            {
              if (str == "--errorcode")
              {
                errorcode = s;
              }
              else
              {
                BootstrapEntrypoint.Usage(string.Format("Invalid argument '{0}'", (object) str));
                return -1;
              }
            }
            else
              assemblyPath = s;
          }
          else
            assemblyPath = s;
        }

As you can see they are setting assemblyPath twice :(

if (string.IsNullOrWhiteSpace(assemblyPath) ^ string.IsNullOrWhiteSpace(empty))
  {
    InternalLogger.NO_OP_LOGGER.LogDebug("Override parameter missing, both lambda-runtime-override-assembly and lambda-runtime-override-type must be specified.");
    return -1;
  }

so this if can never be true :(

from docker-lambda.

romanlum avatar romanlum commented on July 24, 2024

In my implementation I used the internal classes from the original bootstrap.dll so the loading and parsing of the data is the same as with the original runtime

from docker-lambda.

mhart avatar mhart commented on July 24, 2024

@romanlum you are right, it does appear to be a binary compiled from C, not .NET – my apologies!

from docker-lambda.

mhart avatar mhart commented on July 24, 2024

In dotnetcore1.0, the /var/runtime/awslambda binary usage is like this:

awslambda --netcore <coreclr/corefx> --runtime <bootstrap assemblies root> --task <user code root>

I haven't checked if it's the same for 2.0?

from docker-lambda.

romanlum avatar romanlum commented on July 24, 2024

its the same
bash-4.2# ./awslambda
usage:
awslambda
--netcore <coreclr/corefx>
--runtime
--task

from docker-lambda.

jason-riddle avatar jason-riddle commented on July 24, 2024

Is it possible to patch a dll file? Or would it be “easier” just to decompile the dll, fix the bug, and then recompile? Also, I’m guessing that the dll is signed by Amazon correct?

from docker-lambda.

romanlum avatar romanlum commented on July 24, 2024

The dll is not signed, but the native binary awslambda is calling the bootstrap.dll so you cannot add commandline arguments that easy .

If you look at my code in the pull request you can see that i am using the internal UserCodeLoader, so it is the same as if the bootstrap.dll would have been called.

from docker-lambda.

joaoasrosa avatar joaoasrosa commented on July 24, 2024

@mhart there are further developments on this front? Anything where we can help?

from docker-lambda.

jason-riddle avatar jason-riddle commented on July 24, 2024

Update: #68 has been merged which adds support for dotnet core 2.0.

from docker-lambda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.