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.

'dotnet lambda package' throws 'ArgumentNullException' when running for a project with multiple target frameworks

See original GitHub issue

Description

When running dotnet lambda package for a csproj that has multitargetting enabled, a ArgumentNullException exception is throw and the process crashes.

Specifying the -f cmdline option with either netcoreapp3.1 or net5.0 works as expected.

I’d expect either it to work seamlessly, or to return a proper message saying that the target framework needs to be specified.

Reproduction Steps

  1. Create an API lambda project targeting Net Core 3.1 and Net 5.0

Section of csproj:

<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
  1. Run dotnet lambda package in the projects folder
  2. Observe exception is quickly thrown

Logs

Amazon Lambda Tools for .NET Core applications (5.0.0) Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet

Unknown error executing command: Value cannot be null. Parameter name: paths at System.IO.Path.Combine(String[] paths) at Amazon.Lambda.Tools.LambdaPackager.CreateApplicationBundle(LambdaToolsDefaults defaults, IToolLogger logger, String workingDirectory, String projectLocation, String configuration, String targetFramework, String msbuildParameters, Boolean disableVersionCheck, LayerPackageInfo layerPackageInfo, String& publishLocation, String& zipArchivePath) in C:\codebuild\tmp\output\src845572623\src\src\Amazon.Lambda.Tools\LambdaPackager.cs:line 76 at Amazon.Lambda.Tools.Commands.PackageCommand.PerformActionAsync() at Amazon.Common.DotNetCli.Tools.Commands.BaseCommand`1.ExecuteAsync() in C:\codebuild\tmp\output\src845572623\src\src\Amazon.Common.DotNetCli.Tools\Commands\BaseCommand.cs:line 46

Environment

  • OS Info: Windows 10
  • Build Environment: Visual Studio 16.8.2 Developer Command Prompt, Amazon.Lambda.Tools 5.0.0
  • Targeted .NET Platform: netcoreapp3.1 and net5.0

Resolution

  • 👋 I can/would-like-to implement a fix for this problem myself

This is a 🐛 bug-report

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ashishdhingracommented, Mar 3, 2021

Ashish, after updating the tool, I’m now getting a proper validation message back:

PS C:\git\MyProject> dotnet lambda package Amazon Lambda Tools for .NET Core applications (5.0.1) Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet Missing required parameter: --framework

However, I’d suggest improving on the error message: the reason --framework becomes required is due to the project being a multi-target project, however the message could mislead developers into believing the parameter is always required.

Perhaps it would be better to be a bit more specific in the error message. Suggestion:

Missing required parameter for multi-target project: --framework

Having said that, the fact that we are not getting an exception anymore is great.

Hi @julealgon,

Good morning.

I had discussion with the development team and based on their findings, it would not be a simple change in the error message. The code is shared and refactoring it for the error message to include additional checks would impact the overall design and would not be feasible. While I cannot provide the specific details, but it’s good that exception is not thrown anymore for the mentioned scenario. Hence, closing this issue.

Thanks, Ashish

1reaction
normjcommented, Dec 12, 2020

Pull request out for prompting the user if tool doesn’t figure out the target framework. https://github.com/aws/aws-extensions-for-dotnet-cli/pull/151

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - .NET Core Lambda function fails to build deployment ...
I have a .NET Core Lambda function which fails to build the deployment package for AWS Lambda, using the dotnet lambda utility. This...
Read more >
Performance Improvements in .NET 6
Build everything in a release configuration,; build it targeting the .NET Framework 4.8 surface area,; don't exclude any benchmarks,; and run ...
Read more >
Pre 3.5 Release Notes
NUnit 3.5 - October 3, 2016. This is the last version of NUnit where the framework, console runner, engine and extensions are being...
Read more >
How to create maintainable Lambda functions using custom ...
The idea behind this project is simple: use the Template Method pattern to give developers an experience that looks like the one offered...
Read more >
New dependency injection features in .NET 6
This example program will throw an exception when the Scope variable is disposed. Unhandled exception. System.InvalidOperationException: 'Foo' ...
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