'dotnet lambda publish-layer' fails in .NET 6 with ‘--enable-package-optimization true’
See original GitHub issueDescribe the bug
When trying to publish a .NET 6 layer, if you try to enable package optimizations, you will get an exception complaining about crossgen not existing in the tools directory of the .NET 6 SDK. It seems crossgen is no longer included with .NET 6 tools. And it sounds like this is by design according to this issue: https://github.com/dotnet/sdk/issues/24752
Example command that throws the error:
dotnet lambda publish-layer dotnetsixlayer --layer-type runtime-package-store --s3-bucket my-layer-store-bucket --region us-east-1 --package-manifest ./layer-test-manifest.csproj --enable-package-optimization true --framework net6
Either removing the --enable-package-optimization true
or downgrading to .NET 5 fixes the problem.
Expected Behavior
Publishes the layer to the store
Current Behavior
Amazon Lambda Tools for .NET Core applications (5.3.0)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
Warning: Package optimization has been enabled. Be sure to run this on an Amazon Linux environment or the optimization might not be compatbile with the Lambda runtime.
Converted ASP.NET Core project file to temporary package manifest file.
... invoking 'dotnet store' for manifest /tmp/tmpzG6rga.tmp into output directory /tmp/dotnetsixlayer-637849539422701007/dotnetcore/store
... store: Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET
... store: Copyright (C) Microsoft Corporation. All rights reserved.
... store: Determining projects to restore...
... store: Restored /tmp/tmpzG6rga.tmp (in 377 ms).
... store: /usr/share/dotnet/sdk/6.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(82,5): error NETSDK1016: Unable to find resolved path for '/home/ec2-user/.nuget/packages/microsoft.netcore.app.runtime.linux-x64/6.0.3/runtimes/linux-x64/native/../../../tools/crossgen'. [/tmp/tmpzG6rga.tmp]
Error executing the 'dotnet store' command
Reproduction Steps
On an AL2 VM, create a file layer-test-manifest.csproj
with a NuGet reference in it, then run this command:
dotnet lambda publish-layer dotnetsixlayer --layer-type runtime-package-store --s3-bucket my-layer-store-bucket --region us-east-1 --package-manifest ./layer-test-manifest.csproj --enable-package-optimization true --framework net6
Possible Solution
This open issue mentions using FrameworkReferences
Additional Information/Context
No response
Targeted .NET platform
.NET 6
CLI extension version
Package Id Version Commands
amazon.lambda.testtool-3.1 0.12.1 dotnet-lambda-test-tool-3.1 amazon.lambda.testtool-5.0 0.12.0 dotnet-lambda-test-tool-5.0 amazon.lambda.testtool-6.0 0.12.1 dotnet-lambda-test-tool-6.0 amazon.lambda.tools 5.3.0 dotnet-lambda nbgv 3.4.255 nbgv
Environment details (OS name and version, etc.)
Windows 10, Amazon Linux 2
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
@ashishdhingra it looks like Microsoft is removing support for
dotnet store
all together. Do we have a plan to keep functionality with .NET Lambda Layers some other way?Awe shucks, will there be a performance knock at all with remove package optimization? Thank you sir!