Open
Description
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:
- Open WSL2 Ubuntu 22 terminal
- Install prerequisites for a SAM dotnet 7 aot project
- run
sam init
to create a HelloWorld dotnet 7 aot project - run
sam 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:
brad@brad13600:~/dev/dotnet/sam-native-aot$ sam build --debug
2023-04-08 19:16:34,936 | Config file location: /home/brad/dev/dotnet/sam-native-aot/samconfig.toml
2023-04-08 19:16:34,937 | Loading configuration values from [default.['build'].parameters] (env.command_name.section) in config file at '/home/brad/dev/dotnet/sam-native-aot/samconfig.toml'...
2023-04-08 19:16:34,941 | Configuration values successfully loaded.
2023-04-08 19:16:34,941 | Configuration values are: {'stack_name': 'sam-native-aot', 'cached': True, 'parallel': True}
2023-04-08 19:16:34,944 | Using SAM Template at /home/brad/dev/dotnet/sam-native-aot/template.yaml
2023-04-08 19:16:34,969 | Using config file: samconfig.toml, config environment: default
2023-04-08 19:16:34,969 | Expand command line arguments to:
2023-04-08 19:16:34,969 | --template_file=/home/brad/dev/dotnet/sam-native-aot/template.yaml --parallel --mount_with=READ --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache --cached
2023-04-08 19:16:35,062 | 'build' command is called
2023-04-08 19:16:35,062 | Starting Build use cache
2023-04-08 19:16:35,065 | No Parameters detected in the template
2023-04-08 19:16:35,078 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2023-04-08 19:16:35,078 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2023-04-08 19:16:35,079 | 0 stacks found in the template
2023-04-08 19:16:35,079 | No Parameters detected in the template
2023-04-08 19:16:35,088 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2023-04-08 19:16:35,088 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2023-04-08 19:16:35,089 | 2 resources found in the stack
2023-04-08 19:16:35,089 | Found Serverless function with name='HelloWorldFunction' and CodeUri='./src/HelloWorld/'
2023-04-08 19:16:35,089 | --base-dir is not presented, adjusting uri ./src/HelloWorld/ relative to /home/brad/dev/dotnet/sam-native-aot/template.yaml
2023-04-08 19:16:35,092 | 2 resources found in the stack
2023-04-08 19:16:35,092 | Found Serverless function with name='HelloWorldFunction' and CodeUri='./src/HelloWorld/'
2023-04-08 19:16:35,092 | Instantiating build definitions
2023-04-08 19:16:35,094 | Same function build definition found, adding function (Previous: BuildDefinition(provided.al2, /home/brad/dev/dotnet/sam-native-aot/src/HelloWorld, Zip, , 7cc428f0-976a-49a3-be09-9cdb4d3781ab, {'BuildMethod': 'dotnet7'}, {}, x86_64, []), Current: BuildDefinition(provided.al2, /home/brad/dev/dotnet/sam-native-aot/src/HelloWorld, Zip, , 38d5f600-e61e-4a83-9f25-ae301ad9b350, {'BuildMethod': 'dotnet7'}, {}, x86_64, []), Function: Function(function_id='HelloWorldFunction', name='HelloWorldFunction', functionname='HelloWorldFunction', runtime='provided.al2', memory=256, timeout=10, handler='bootstrap', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='/home/brad/dev/dotnet/sam-native-aot/src/HelloWorld', environment={'Variables': {'PARAM1': 'VALUE'}}, rolearn=None, layers=[], events={'HelloWorld': {'Type': 'Api', 'Properties': {'Path': '/hello', 'Method': 'get', 'RestApiId': 'ServerlessRestApi'}}}, metadata={'BuildMethod': 'dotnet7', 'SamResourceId': 'HelloWorldFunction'}, inlinecode=None, codesign_config_arn=None, architectures=['x86_64'], function_url_config=None, stack_path='', runtime_management_config=None))
2023-04-08 19:16:35,095 | Async execution started
2023-04-08 19:16:35,095 | Invoking function functools.partial(<bound method ParallelBuildStrategy.build_single_function_definition of <samcli.lib.build.build_strategy.ParallelBuildStrategy object at 0x7fbe5c056bd0>>, <samcli.lib.build.build_graph.FunctionBuildDefinition object at 0x7fbe5bfb2e10>)
2023-04-08 19:16:35,095 | Running incremental build for runtime provided.al2 for following resources (HelloWorldFunction)
2023-04-08 19:16:35,096 | Waiting for async results
2023-04-08 19:16:35,451 | Cache is invalid, running build and copying resources for following functions (HelloWorldFunction)
2023-04-08 19:16:35,451 | Building codeuri: /home/brad/dev/dotnet/sam-native-aot/src/HelloWorld runtime: provided.al2 metadata: {'BuildMethod': 'dotnet7'} architecture: x86_64 functions: HelloWorldFunction
2023-04-08 19:16:35,451 | Building to following folder /home/brad/dev/dotnet/sam-native-aot/.aws-sam/build/HelloWorldFunction
2023-04-08 19:16:35,452 | Loading workflow module 'aws_lambda_builders.workflows'
2023-04-08 19:16:35,453 | Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'
2023-04-08 19:16:35,454 | Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
2023-04-08 19:16:35,454 | Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
2023-04-08 19:16:35,455 | Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2023-04-08 19:16:35,456 | Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
2023-04-08 19:16:35,456 | Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
2023-04-08 19:16:35,457 | Registering workflow 'NodejsNpmEsbuildBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)'
2023-04-08 19:16:35,458 | Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2023-04-08 19:16:35,458 | Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
2023-04-08 19:16:35,459 | Registering workflow 'RustCargoLambdaBuilder' with capability 'Capability(language='rust', dependency_manager='cargo', application_framework=None)'
2023-04-08 19:16:35,459 | Found workflow 'DotnetCliPackageBuilder' to support capabilities 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
2023-04-08 19:16:35,565 | Running workflow 'DotnetCliPackageBuilder'
2023-04-08 19:16:35,565 | Running DotnetCliPackageBuilder:GlobalToolInstall
2023-04-08 19:16:35,565 | Entered synchronized block for updating Amazon.Lambda.Tools
2023-04-08 19:16:35,565 | Installing Amazon.Lambda.Tools Global Tool
2023-04-08 19:16:35,565 | executing dotnet: ['dotnet', 'tool', 'install', '-g', 'Amazon.Lambda.Tools', '--ignore-failed-sources']
2023-04-08 19:16:35,810 |
2023-04-08 19:16:35,810 | Error installing probably due to already installed. Attempt to update to latest version.
2023-04-08 19:16:35,810 | executing dotnet: ['dotnet', 'tool', 'update', '-g', 'Amazon.Lambda.Tools', '--ignore-failed-sources']
2023-04-08 19:16:37,566 | Tool 'amazon.lambda.tools' was reinstalled with the latest stable version (version '5.6.4').
2023-04-08 19:16:37,567 | DotnetCliPackageBuilder:GlobalToolInstall succeeded
2023-04-08 19:16:37,567 | Running DotnetCliPackageBuilder:RunPackageAction
2023-04-08 19:16:37,567 | Running `dotnet lambda package` in /home/brad/dev/dotnet/sam-native-aot/src/HelloWorld
2023-04-08 19:16:37,567 | executing dotnet: ['dotnet', 'lambda', 'package', '--output-package', '/home/brad/dev/dotnet/sam-native-aot/.aws-sam/build/HelloWorldFunction/HelloWorld.zip', '--msbuild-parameters', '--runtime linux-x64']
2023-04-08 19:16:40,301 | 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
Found /etc/os-release
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-48ed7f21-d7d1-4f01-ac89-3d916d1fc1b0 --rm --volume "/home/brad/dev/dotnet/sam-native-aot/src/HelloWorld":/tmp/source/ -i -u 1000:1000 -e DOTNET_CLI_HOME=/tmp/dotnet -e XDG_DATA_HOME=/tmp/xdg 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 /home/brad/dev/dotnet/sam-native-aot/src/HelloWorld
... docker run: MSBuild version 17.5.0+6f08c67f3 for .NET
... docker run: MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
ERROR: Container build returned 1
Failed to create application package
2023-04-08 19:16:40,301 | DotnetCliPackageBuilder:RunPackageAction failed
Traceback (most recent call last):
File "aws_lambda_builders/workflows/dotnet_clipackage/actions.py", line 108, in execute
File "aws_lambda_builders/workflows/dotnet_clipackage/dotnetcli.py", line 66, in run
aws_lambda_builders.workflows.dotnet_clipackage.dotnetcli.DotnetCLIExecutionError: Dotnet CLI Failed:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "aws_lambda_builders/workflow.py", line 369, in run
File "aws_lambda_builders/workflows/dotnet_clipackage/actions.py", line 115, in execute
aws_lambda_builders.actions.ActionFailedError: Dotnet CLI Failed:
2023-04-08 19:16:40,303 | Exception raised during the execution
There is a /src/HelloWorld/HelloWorld.csproj
file that is created by sam 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:
brad@brad13600:~/dev/dotnet/sam-native-aot$ docker run --name tempLambdaBuildContainer-48ed7f21-d7d1-4f01-ac89-3d916d1fc1b0 --rm --volume "/home/brad/dev/dotnet/sam-native-aot/src/HelloWorld":/tmp/source/ -i -u 1000:1000 -e DOTNET_CLI_HOME=/tmp/dotnet -e XDG_DATA_HOME=/tmp/xdg 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
MSBuild version 17.5.0+6f08c67f3 for .NET
Determining projects to restore...
Restored /tmp/source/HelloWorld.csproj (in 7.03 sec).
HelloWorld -> /tmp/source/bin/Release/net7.0/linux-x64/bootstrap.dll
HelloWorld -> /tmp/source/bin/Release/net7.0/publish/
docker run
also works if I cd into the .src/HelloWorld
folder first:
brad@brad13600:~/dev/dotnet/sam-native-aot/src$ cd /home/brad/dev/dotnet/sam-native-aot/src/HelloWorld
brad@brad13600:~/dev/dotnet/sam-native-aot/src/HelloWorld$ docker run --name tempLambdaBuildContainer-48ed7f21-d7d1-4f01-ac89-3d916d1fc1b0 --rm --volume "/home/brad/dev/dotnet/sam-native-aot/src/HelloWorld":/tmp/source/ -i -u 1000:1000 -e DOTNET_CLI_HOME=/tmp/dotnet -e XDG_DATA_HOME=/tmp/xdg 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
MSBuild version 17.5.0+6f08c67f3 for .NET
Determining projects to restore...
Restored /tmp/source/HelloWorld.csproj (in 7.21 sec).
HelloWorld -> /tmp/source/bin/Release/net7.0/linux-x64/bootstrap.dll
HelloWorld -> /tmp/source/bin/Release/net7.0/publish/
Observed result:
sam build
fails
Expected result:
sam build
should succeed
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
{
"version": "1.79.0",
"system": {
"python": "3.7.10",
"os": "Linux-5.15.90.1-microsoft-standard-WSL2-x86_64-with-debian-bookworm-sid"
},
"additional_dependencies": {
"docker_engine": "20.10.23",
"aws_cdk": "Not available",
"terraform": "Not available"
}
}
- I am using Docker Desktop instead of Docker Community Edition
- I have not tried this outside of WSL2/Ubuntu 22
- I installed
dotnet
using the Microsoft repo instead of the Ubuntu repo