{"id":1615,"date":"2019-09-24T01:42:19","date_gmt":"2019-09-23T15:42:19","guid":{"rendered":"https:\/\/ntsblog.homedev.com.au\/?p=1615"},"modified":"2020-04-15T21:39:40","modified_gmt":"2020-04-15T11:39:40","slug":"aws-package-a-lambda","status":"publish","type":"post","link":"https:\/\/ntsblog.homedev.com.au\/index.php\/2019\/09\/24\/aws-package-a-lambda\/","title":{"rendered":"AWS Package a Lambda"},"content":{"rendered":"<div id=\"ntsbl-2809308528\" class=\"ntsbl-before-content ntsbl-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-6288941070289539\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:inline-block;width:728px;height:90px;\" \ndata-ad-client=\"ca-pub-6288941070289539\" \ndata-ad-slot=\"9356781486\"><\/ins> \n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div><h2>The Problem<\/h2>\n<p>You have built a .net core based AWS lambda package and now you wish to publish it.<\/p>\n<p>Googling the internet you find that this can be done by running the following script:<\/p>\n<pre>dotnet lambda package -o ..\\lambda-1.zip<\/pre>\n<p>It throws the error: &#8220;dotnet : No executeable found matching command &#8220;dotnet-lambda&#8221;<\/p>\n<h2>The Issue<\/h2>\n<p>You Lambda project requires some special tools that provide the aws lambda packager.<\/p>\n<h2>The Solution .net core 2.x<\/h2>\n<p>Edit your .net core project file and ensure that the following block exists as an item group<\/p>\n<pre><itemgroup>\n    <dotnetclitoolreference include=\"Amazon.Lambda.Tools\" version=\"2.2.0\">\n<\/dotnetclitoolreference><\/itemgroup>\n<\/pre>\n<p>Restore the packages, (dotnet restore), and retry the &#8220;package&#8221; command and the lambda should now build and be packed into your lambda-1.zip file.<\/p>\n<h2>The Solution .net core 3.x<\/h2>\n<p>In .net core 3.x, things have changed and you no longer need to include the client tool reference as part of the project file.<\/p>\n<p>Instead you need to install the Amazon Lambda tools as a globally accessible tool. Run the following common to install<\/p>\n<pre>dotnet tool install --global Amazon.Lambda.Tools\n<\/pre>\n<p>The nuget package details are here:<br \/>\n<a href=\"https:\/\/www.nuget.org\/packages\/Amazon.Lambda.Tools\">https:\/\/www.nuget.org\/packages\/Amazon.Lambda.Tools<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>dotnet lambda package &#8230; No executeable found matching command &#8220;dotnet-lambda&#8221;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[32,33],"tags":[],"class_list":["post-1615","post","type-post","status-publish","format-standard","hentry","category-aws","category-lambda"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts\/1615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/comments?post=1615"}],"version-history":[{"count":0,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts\/1615\/revisions"}],"wp:attachment":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/media?parent=1615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/categories?post=1615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/tags?post=1615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}