-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Describe the bug
When migrating a .NET Lambda project that uses Native AOT to slnx, the build fails because the referenced shared project cannot be found.
https://devblogs.microsoft.com/dotnet/introducing-slnx-support-dotnet-cli/
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
I expected the project to build and the lambda to be deployed.
Output
Amazon Lambda Tools for .NET Core applications (5.13.0)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
Found /etc/os-release
Found /etc/os-release
Executing publish command
Starting container for native AOT build using build image: public.ecr.aws/sam/build-dotnet8:latest-x86_64.
... invoking 'docker run --name tempLambdaBuildContainer-db2095a3-89aa-4a22-bf3e-37eb8e2657ee --rm --volume "/home/oskar/temp/BlogFunction":/tmp/source/ -i -u 1000:1000 -e DOTNET_CLI_HOME=/tmp/dotnet -e XDG_DATA_HOME=/tmp/xdg public.ecr.aws/sam/build-dotnet8:latest-x86_64 dotnet publish "/tmp/source/src/BlogFunction" --output "/tmp/source/src/BlogFunction/bin/Release/net8.0/publish" --configuration "Release" --framework "net8.0" /p:GenerateRuntimeConfigurationFiles=true --runtime linux-x64 --self-contained True /p:StripSymbols=true' from directory /home/oskar/temp/BlogFunction
... docker run: An issue was encountered verifying workloads. For more information, run "dotnet workload update".
... docker run: Determining projects to restore...
... docker run: Restored /tmp/source/src/BlogFunction.Shared/BlogFunction.Shared.csproj (in 2.48 sec).
... docker run: Restored /tmp/source/src/BlogFunction/BlogFunction.csproj (in 3.82 sec).
... docker run: BlogFunction.Shared -> /tmp/source/src/BlogFunction.Shared/bin/Release/net8.0/BlogFunction.Shared.dll
Current Behavior
The project fails to build
Output
Amazon Lambda Tools for .NET Core applications (5.13.0)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
Found /etc/os-release
Found /etc/os-release
Executing publish command
Starting container for native AOT build using build image: public.ecr.aws/sam/build-dotnet8:latest-x86_64.
... invoking 'docker run --name tempLambdaBuildContainer-9b013d41-703c-4d77-aa3b-677a359793cd --rm --volume "/home/oskar/temp/BlogFunction/src/BlogFunction":/tmp/source/ -i -u 1000:1000 -e DOTNET_CLI_HOME=/tmp/dotnet -e XDG_DATA_HOME=/tmp/xdg public.ecr.aws/sam/build-dotnet8:latest-x86_64 dotnet publish "/tmp/source/" --output "/tmp/source/bin/Release/net8.0/publish" --configuration "Release" --framework "net8.0" /p:GenerateRuntimeConfigurationFiles=true --runtime linux-x64 --self-contained True /p:StripSymbols=true' from directory /home/oskar/temp/BlogFunction/src/BlogFunction
... docker run: An issue was encountered verifying workloads. For more information, run "dotnet workload update".
... docker run: Determining projects to restore...
... docker run: Skipping project "/tmp/BlogFunction.Shared/BlogFunction.Shared.csproj" because it was not found.
... docker run: Skipping project "/tmp/BlogFunction.Shared/BlogFunction.Shared.csproj" because it was not found.
... docker run: Restored /tmp/source/BlogFunction.csproj (in 3.61 sec).
... docker run: /var/lang/bin/sdk/8.0.414/Microsoft.Common.CurrentVersion.targets(2176,5): warning : The referenced project '../BlogFunction.Shared/BlogFunction.Shared.csproj' does not exist. [/tmp/source/BlogFunction.csproj]
... docker run: /tmp/source/Function.cs(2,20): error CS0234: The type or namespace name 'Shared' does not exist in the namespace 'BlogFunction' (are you missing an assembly reference?) [/tmp/source/BlogFunction.csproj]
ERROR: Container build returned 1
Reproduction Steps
Create a new lambda project with a shared library
dotnet new lambda.EmptyFunction --name BlogFunction --profile default --region us-east-2
cd BlogFunction
dotnet new sln
dotnet sln add src/BlogFunction/BlogFunction.csproj
dotnet sln add test/BlogFunction.Tests/BlogFunction.Tests.csproj
dotnet new classlib --framework "net8.0" -o src/BlogFunction.Shared
dotnet sln add src/BlogFunction.Shared/BlogFunction.Shared.csproj
dotnet reference add src/BlogFunction.Shared/BlogFunction.Shared.csproj --project src/BlogFunction/BlogFunction.csproj
Make sure that the lambda function is a AOT project edit BlogFunction.csproj to:
Exe net8.0 enable enable Lambda true true true partialVerify that it works
cd src/BlogFunction/
dotnet lambda deploy-function
Output
Amazon Lambda Tools for .NET Core applications (5.13.0)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
Found /etc/os-release
Found /etc/os-release
Executing publish command
Starting container for native AOT build using build image: public.ecr.aws/sam/build-dotnet8:latest-x86_64.
... invoking 'docker run --name tempLambdaBuildContainer-db2095a3-89aa-4a22-bf3e-37eb8e2657ee --rm --volume "/home/oskar/temp/BlogFunction":/tmp/source/ -i -u 1000:1000 -e DOTNET_CLI_HOME=/tmp/dotnet -e XDG_DATA_HOME=/tmp/xdg public.ecr.aws/sam/build-dotnet8:latest-x86_64 dotnet publish "/tmp/source/src/BlogFunction" --output "/tmp/source/src/BlogFunction/bin/Release/net8.0/publish" --configuration "Release" --framework "net8.0" /p:GenerateRuntimeConfigurationFiles=true --runtime linux-x64 --self-contained True /p:StripSymbols=true' from directory /home/oskar/temp/BlogFunction
... docker run: An issue was encountered verifying workloads. For more information, run "dotnet workload update".
... docker run: Determining projects to restore...
... docker run: Restored /tmp/source/src/BlogFunction.Shared/BlogFunction.Shared.csproj (in 2.48 sec).
... docker run: Restored /tmp/source/src/BlogFunction/BlogFunction.csproj (in 3.82 sec).
... docker run: BlogFunction.Shared -> /tmp/source/src/BlogFunction.Shared/bin/Release/net8.0/BlogFunction.Shared.dll
Migrate to slnx
cd ../../
dotnet sln migrate
rm BlogFunction.sln
cd src/BlogFunction/
dotnet lambda deploy-function
Output
Amazon Lambda Tools for .NET Core applications (5.13.0)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
Found /etc/os-release
Found /etc/os-release
Executing publish command
Starting container for native AOT build using build image: public.ecr.aws/sam/build-dotnet8:latest-x86_64.
... invoking 'docker run --name tempLambdaBuildContainer-9b013d41-703c-4d77-aa3b-677a359793cd --rm --volume "/home/oskar/temp/BlogFunction/src/BlogFunction":/tmp/source/ -i -u 1000:1000 -e DOTNET_CLI_HOME=/tmp/dotnet -e XDG_DATA_HOME=/tmp/xdg public.ecr.aws/sam/build-dotnet8:latest-x86_64 dotnet publish "/tmp/source/" --output "/tmp/source/bin/Release/net8.0/publish" --configuration "Release" --framework "net8.0" /p:GenerateRuntimeConfigurationFiles=true --runtime linux-x64 --self-contained True /p:StripSymbols=true' from directory /home/oskar/temp/BlogFunction/src/BlogFunction
... docker run: An issue was encountered verifying workloads. For more information, run "dotnet workload update".
... docker run: Determining projects to restore...
... docker run: Skipping project "/tmp/BlogFunction.Shared/BlogFunction.Shared.csproj" because it was not found.
... docker run: Skipping project "/tmp/BlogFunction.Shared/BlogFunction.Shared.csproj" because it was not found.
... docker run: Restored /tmp/source/BlogFunction.csproj (in 3.61 sec).
... docker run: /var/lang/bin/sdk/8.0.414/Microsoft.Common.CurrentVersion.targets(2176,5): warning : The referenced project '../BlogFunction.Shared/BlogFunction.Shared.csproj' does not exist. [/tmp/source/BlogFunction.csproj]
... docker run: /tmp/source/Function.cs(2,20): error CS0234: The type or namespace name 'Shared' does not exist in the namespace 'BlogFunction' (are you missing an assembly reference?) [/tmp/source/BlogFunction.csproj]
ERROR: Container build returned 1
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
Amazon Lambda Tools for .NET Core applications (5.13.0)
.NET SDK 8.0.415
Docker version 28.3.3, build 980b856
Targeted .NET Platform
NET 8.0
Operating System and version
Ubuntu 24.04.3 LTS