LambdaNETCoreSamples icon indicating copy to clipboard operation
LambdaNETCoreSamples copied to clipboard

Self Contained project requires RuntimeIdentifier to be specified

Open badcommandorfilename opened this issue 7 years ago • 3 comments

Great resource, thanks for making this! I just hit one snag when trying to deploy a netcore2.2 serverless project to Lambda/ApiGateway. I got the error:

/var/task/bootstrap: line 6: /var/task/projectname: cannot execute binary file

The .csproj <PropertyGroup> needs to have <RuntimeIdentifier>ubuntu.16.10-x64</RuntimeIdentifier> specified to deploy to lambda correctly.

Possibly this is just needed for Windows/Visual Studio 2019 development, but this is needed to generate the linux executable in /var/task/ that the bootstrap script runs.

Hopefully this helps someone. I'd make a pull request, but I'm too lazy =P

badcommandorfilename avatar May 30 '19 06:05 badcommandorfilename

Thanks. This helped with not getting the 'No such file or directory' error anymore from the bootstrap file.

However locally I am not getting the .exe file anymore and it's causing an "ANCM In-Process Handler Load Failure" error. I see the .dll only. Plus the files now are under a 'ubuntu.16.10-x64' subfolder under netcoreapp3.0 folder.

abukres avatar Oct 16 '19 02:10 abukres

Hi @abukres - I'm developing on Windows too and then deploying to serverless (ubuntu) as well.

What you need is a <RuntimeIdentifier Condition=" '$(Configuration)' == 'Local' ">win10-x64</RuntimeIdentifier>:

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
    <AWSProjectType>Lambda</AWSProjectType>
    <Configurations>Debug;Release</Configurations>
    <RuntimeIdentifier>ubuntu.16.10-x64</RuntimeIdentifier>
    <RuntimeIdentifier Condition=" '$(Configuration)' == 'Debug' ">win10-x64</RuntimeIdentifier>
    <NoWin32Manifest>true</NoWin32Manifest>
  </PropertyGroup>

Also as a sidenote, the Amazon Visual Studio Plugin only supports "Debug" or "Release" configurations when deploying.

badcommandorfilename avatar Dec 04 '19 03:12 badcommandorfilename

Sorry I never responded to this sooner but this is now out of date. To reduce cold starts the blueprint was custom runtime samples have been reworked to have the .NET assembly be called bootstrap instead of having a script called bootstrap. That avoids having to start up 2 separate processes.

normj avatar Sep 28 '21 05:09 normj