question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New .NET Core 3.1 Lambda template: `dotnet lambda deploy-function` attempts to publish netcore-2.1 app

See original GitHub issue

Description

After installing the AWS lambda toolkit, and then creating a new Lambda function using the VS project templates, attempting to publish the app fails with the error

doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project.

This appears to be caused by the fact that the new project template used generates using the NETCORE-3.1 framework, but the lambda defaults file still says 2.0

Reproduction Steps

  • Install AWS VS tools
  • Create new Lambda c# project (SQS listener)
  • Install Lambda dotnet tools using dotnet tool install -g Amazon.Lambda.Tools
  • run dotnet lambda deploy-function from the Developer Commandline.

Logs

D:\Code\LambdaSample>dotnet lambda deploy-function
Amazon Lambda Tools for .NET Core applications (4.1.0)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet

--------------------------------------------------------------------------------
.NET Core 2.0 Lambda Function Deprecation Notice
--------------------------------------------------------------------------------
Support for .NET Core 2.0 Lambda functions will soon be deprecated.

Support for .NET Core 2.0 was discontinued by Microsoft in October 2018.  This
version of the runtime is no longer receiving bug fixes or security updates from
Microsoft.  AWS Lambda has discontinued updates to this runtime as well.

You can find Lambda's runtime support policy here:
https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html

You will notice an initial change 30 days prior to the deprecation.
During the 30 day grace period you will be able to update existing .NET Core 2.0
Lambda functions but you will not be able to create new ones.  After the
deprecation has been finalized you will be unable to create or update .NET Core
2.0 functions.

However, both during and after the grace period you WILL be able to invoke .NET
Core 2.0 functions.  Existing .NET Core 2.0 function invocation will continue to
be available, subject to Lambda's runtime support policy.

--------------------------------------------------------------------------------
Executing publish command
... invoking 'dotnet publish', working folder 'D:\Code\LambdaSample\bin\Release\netcoreapp2.0\publish'
... Disabling compilation context to reduce package size. If compilation context is needed pass in the "/p:PreserveCompilationContext=false" switch.
... dotnet publish --output "D:\Code\LambdaSample\bin\Release\netcoreapp2.0\publish" --configuration "Release" --framework "netcoreapp2.0" /p:GenerateRuntimeConfigurationFiles=true --runtime rhel.7.2-x64 --self-contained false  /p:PreserveCompilationContext=false --manifest "C:\Users\dougr\AppData\Local\Temp\tmp1D81.tmp"
... publish: Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
... publish: Copyright (C) Microsoft Corporation. All rights reserved.
... publish:   Restore completed in 186.99 ms for D:\Code\LambdaSample\LambdaSample.csproj.
... publish: c:\program files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1005: Assets file 'D:\Code\LambdaSample\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. [D:\Code\LambdaSample\LambdaSample.csproj]

aws-lambda-tools-default.json (note incorrect framework created from sample):

{
  "Information": [
    "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
    "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
    "dotnet lambda help",
    "All the command line options for the Lambda command can be specified in this file."
  ],
  "profile": "cli-session",
  "region": "us-west-2",
  "configuration": "Release",
  ___"framework": "netcoreapp2.0",___
  "function-runtime": "dotnetcore3.1",
  "function-memory-size": 256,
  "function-timeout": 30,
  "function-handler": "LambdaSample::LambdaSample.Function::FunctionHandler"
}

Environment

  • Build Version:
  • Amazon.Lambda.Core 1.1.0
  • Amazon.Lambda.Serialization.System.TextJs 2.0.0
  • Amazon.Lambda.SQSEvents 1.1.0
  • OS Info: Windows 10 Pro 1909
  • Build Environment: dotnet CLI used via Developer Command Prompt
  • Targeted .NET Platform: netcore 3.1

This is a 🐛 bug-report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ashishdhingracommented, Sep 23, 2020

Reproducible using the command:

dotnet new lambda.SQS --name MyFunction

which generates the following aws.lambda.tools-defaults.json:

{
  "Information": [
    "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
    "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
    "dotnet lambda help",
    "All the command line options for the Lambda command can be specified in this file."
  ],
  "profile": "",
  "region": "",
  "configuration": "Release",
  "framework": "netcoreapp2.0",
  "function-runtime": "dotnetcore2.0",
  "function-memory-size": 256,
  "function-timeout": 30,
  "function-handler": "MyFunction::MyFunction.Function::FunctionHandler"
}
0reactions
github-actions[bot]commented, Dec 8, 2020

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploying an AWS Lambda Project with the .NET Core CLI
Enter dotnet lambda deploy-function . When prompted, enter the name of the function to deploy. It can be a new name or the...
Read more >
How do I build a Lambda deployment package for C# .NET?
1. Install the default Lambda .NET templates and add the Amazon.Lambda.Tools extension to the .NET Core CLI by running the following command: dotnet...
Read more >
Using Powershell to perform the .Netcore Visual Studio ...
To deploy from the command line, use the dotnet CLI extension for Lambda. It's the same code that runs inside Visual Studio when...
Read more >
Create & Deploy a Hello World .NET Core 3.1 AWS ...
This tutorial will walk you through how to set up your development environment, then create & deploy a simple .NET Core 3.1 Lambda...
Read more >
Hosting ASP.NET Core Web API with AWS Lambda
In this article, we will learn about hosting ASP.NET Core Web API with AWS Lambda in a rather simple-to-follow manner. It is going...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found