Open bradthurber opened 1 year ago
I decided to try sam build
in Windows instead of WSL2 and it works there. Updating title of issue to note WSL2 as it seems to work fine in straight windows.
PS C:\Users\bradt\Documents\temporary\dotnet7-aot-win> sam build
Starting Build use cache
Cache is invalid, running build and copying resources for following functions (HelloWorldFunction)
Building codeuri: C:\Users\bradt\Documents\temporary\dotnet7-aot-win\src\HelloWorld runtime: provided.al2 metadata: {'BuildMethod': 'dotnet7'} architecture: x86_64 functions: HelloWorldFunction
Running DotnetCliPackageBuilder:GlobalToolInstall
Tool 'amazon.lambda.tools' was reinstalled with the latest stable version (version '5.6.4').
Running DotnetCliPackageBuilder:RunPackageAction
Amazon Lambda Tools for .NET Core applications (5.6.4)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
Architecture not provided, defaulting to x86_64 for container build image.
Executing publish command
Starting container for native AOT build using build image: public.ecr.aws/sam/build-dotnet7:latest-x86_64.
... invoking 'docker run --name tempLambdaBuildContainer-6efb532a-4c1a-4b77-8434-05f5515c1714 --rm --volume "C:\Users\bradt\Documents\temporary\dotnet7-aot-win\src\HelloWorld":/tmp/source/ -i public.ecr.aws/sam/build-dotnet7:latest-x86_64 dotnet publish "/tmp/source/" --output "/tmp/source\bin\Release\net7.0\publish" --configuration "Release" --framework "net7.0" --runtime linux-x64 /p:GenerateRuntimeConfigurationFiles=true --self-contained True /p:StripSymbols=true' from directory C:\Users\bradt\Documents\temporary\dotnet7-aot-win\src\HelloWorld
... docker run: MSBuild version 17.5.0+6f08c67f3 for .NET
... docker run: Determining projects to restore...
... docker run: Restored /tmp/source/HelloWorld.csproj (in 6.77 sec).
... docker run: /tmp/source/Function.cs(53,24): warning IL3050: Using member 'System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications. [/tmp/source/HelloWorld.csproj]
... docker run: /tmp/source/Function.cs(53,24): warning IL2026: Using member 'System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved. [/tmp/source/HelloWorld.csproj]
... docker run: HelloWorld -> /tmp/source/bin/Release/net7.0/linux-x64/bootstrap.dll
... docker run: Generating native code
... docker run: /tmp/source/Function.cs(51): Trim analysis warning IL2026: HelloWorld.Function.<FunctionHandler>d__3.MoveNext(): Using member 'System.Text.Json.JsonSerializer.Serialize<Dictionary`2<String,String>>(Dictionary`2<String,String>,JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved. [/tmp/source/HelloWorld.csproj]
... docker run: /tmp/source/Function.cs(51): AOT analysis warning IL3050: HelloWorld.Function.<FunctionHandler>d__3.MoveNext(): Using member 'System.Text.Json.JsonSerializer.Serialize<Dictionary`2<String,String>>(Dictionary`2<String,String>,JsonSerializerOptions)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications. [/tmp/source/HelloWorld.csproj]
... docker run: /tmp/dotnet/.nuget/packages/amazon.lambda.serialization.systemtextjson/2.3.0/lib/net6.0/Amazon.Lambda.Serialization.SystemTextJson.dll : warning IL2104: Assembly 'Amazon.Lambda.Serialization.SystemTextJson' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [/tmp/source/HelloWorld.csproj]
... docker run: /tmp/dotnet/.nuget/packages/amazon.lambda.serialization.systemtextjson/2.3.0/lib/net6.0/Amazon.Lambda.Serialization.SystemTextJson.dll : warning IL3053: Assembly 'Amazon.Lambda.Serialization.SystemTextJson' produced AOT analysis warnings. [/tmp/source/HelloWorld.csproj]
... docker run: /tmp/dotnet/.nuget/packages/amazon.lambda.runtimesupport/1.8.2/lib/net6.0/Amazon.Lambda.RuntimeSupport.dll : warning IL2104: Assembly 'Amazon.Lambda.RuntimeSupport' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [/tmp/source/HelloWorld.csproj]
... docker run: /tmp/dotnet/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/7.0.4/framework/System.Linq.Expressions.dll : warning IL3053: Assembly 'System.Linq.Expressions' produced AOT analysis warnings. [/tmp/source/HelloWorld.csproj]
... docker run: HelloWorld -> /tmp/source/bin/Release/net7.0/publish/
Missing deps.json file. Skipping flattening runtime folder because is an unrecognized format
Zipping publish folder C:\Users\bradt\Documents\temporary\dotnet7-aot-win\src\HelloWorld\bin\Release\net7.0\publish to C:\Users\bradt\Documents\temporary\dotnet7-aot-win\.aws-sam\build\HelloWorldFunction\HelloWorld.zip
Creating directory C:\Users\bradt\Documents\temporary\dotnet7-aot-win\.aws-sam\build\HelloWorldFunction
... zipping: bootstrap
Created publish archive (C:\Users\bradt\Documents\temporary\dotnet7-aot-win\.aws-sam\build\HelloWorldFunction\HelloWorld.zip).
Lambda project successfully packaged: C:\Users\bradt\Documents\temporary\dotnet7-aot-win\.aws-sam\build\HelloWorldFunction\HelloWorld.zip
Build Succeeded
Built Artifacts : .aws-sam\build
Built Template : .aws-sam\build\template.yaml
Commands you can use next
=========================
[*] Validate SAM template: sam validate
[*] Invoke Function: sam local invoke
[*] Test Function in the Cloud: sam sync --stack-name {{stack-name}} --watch
[*] Deploy: sam deploy --guided
PS C:\Users\bradt\Documents\temporary\dotnet7-aot-win>
Thanks for opening the issue, just wondering for the sam installation for the WSL2 system, which installer did you use?
for the sam installation for the WSL2 system, which installer did you use?
Hi. Thank you for reviewing this issue. I use this bash script to install and update SAM at the Ubuntu Linux prompt:
#!/bin/bash -e
# https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html#cliv2-linux-install
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-completion.html
echo "make sure OS is up-to-date"
sudo apt update && sudo apt upgrade -y
sudo apt install unzip -y
echo "* Switching to new temporary tmp folder..."
pushd "$(mktemp -d)"
echo
echo "* Downloading the AWS SAM CLI installer for linux"
wget https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip -O aws-sam-cli-linux-x86_64.zip
echo
echo "* Unzipping it..."
unzip -q aws-sam-cli-linux-x86_64.zip
echo
if [ -f /usr/local/aws-sam-cli/current/bin/sam ]; then
echo "* Current version:"
/usr/local/aws-sam-cli/current/bin/sam --version
echo "* Updating..."
sudo ./install --update
else
echo "* Installing..."
sudo ./install
fi
echo
echo "* Installed version:"
sam --version
echo
echo "Resuming at original directory"
popd
Does exist any solution for this? I'm having exact same issue
Description:
sam build
fails after creating the out-of-the-box HelloWorld dotnet 7 aot project [in a WSL2/Ubuntu/Bash environment but seems to work fine a pure Windows environment - Brad 4/10/2023].I use SAM for Python projects, but this is my first-time trying SAM in the dotnet world. I don't know much about dotnet either - so keep that in mind.
Steps to reproduce:
sam init
to create a HelloWorld dotnet 7 aot projectsam build --debug
and get an error:... docker run: MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
.Detailed
sam build --debug
log:There is a
/src/HelloWorld/HelloWorld.csproj
file that is created bysam init
.I noticed the
docker run
command in the log - so I tried to run that manually as a troubleshooting step - and that seems to work - which is odd:docker run
also works if I cd into the.src/HelloWorld
folder first:Observed result:
sam build
failsExpected result:
sam build
should succeedAdditional environment details (Ex: Windows, Mac, Amazon Linux etc)
dotnet
using the Microsoft repo instead of the Ubuntu repo