Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sam Build fails when publishing against dotnet8 runtime #6771

Closed
mldasco opened this issue Mar 3, 2024 · 2 comments
Closed

Sam Build fails when publishing against dotnet8 runtime #6771

mldasco opened this issue Mar 3, 2024 · 2 comments
Labels
stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Comments

@mldasco
Copy link

mldasco commented Mar 3, 2024

Description:

sam build fails after I upgrade to my solution to dotnet8 runtime. Downgrading back to dotnet6 runtime works.
Problem seems to be that upon publishing it's working folder is set to /net6.0/ rather than /net8.0/

Steps to reproduce:

  1. Start with .net project with <TargetFramework>net6.0</TargetFramework>
  2. Update csproj files to <TargetFramework>net8.0</TargetFramework>
  3. Update template.yaml file to Runtime: dotnet8
  4. Run sam build --debug and observe build failed

Detailed sam build --debug log:

qhponds-tennis-lockcode-generator % sam build --debug                  
2024-03-03 21:08:35,347 | Config file location: /Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/samconfig.toml                                                                                
2024-03-03 21:08:35,350 | Loading configuration values from [default.['build'].parameters] (env.command_name.section) in config file at                                                                              
'/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/samconfig.toml'...                                                                                                                           
2024-03-03 21:08:35,351 | Configuration values successfully loaded.                                                                                                                                                  
2024-03-03 21:08:35,352 | Configuration values are: {}                                                                                                                                                               
2024-03-03 21:08:35,355 | Using SAM Template at /Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/template.yaml                                                                                 
2024-03-03 21:08:35,389 | Using config file: samconfig.toml, config environment: default                                                                                                                             
2024-03-03 21:08:35,390 | Expand command line arguments to:                                                                                                                                                          
2024-03-03 21:08:35,391 | --template_file=/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/template.yaml --mount_with=READ --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache               
2024-03-03 21:08:35,429 | 'build' command is called                                                                                                                                                                  
2024-03-03 21:08:35,433 | No Parameters detected in the template                                                                                                                                                     
2024-03-03 21:08:35,486 | There is no customer defined id or cdk path defined for resource LambdaEntryFunctionHandler, so we will use the resource logical id as the resource id                                     
2024-03-03 21:08:35,487 | 0 stacks found in the template                                                                                                                                                             
2024-03-03 21:08:35,488 | No Parameters detected in the template                                                                                                                                                     
2024-03-03 21:08:35,521 | There is no customer defined id or cdk path defined for resource LambdaEntryFunctionHandler, so we will use the resource logical id as the resource id                                     
2024-03-03 21:08:35,522 | 1 resources found in the stack                                                                                                                                                             
2024-03-03 21:08:35,523 | Found Serverless function with name='LambdaEntryFunctionHandler' and CodeUri='./src/QhPonds.Tennis.LockCodeGenerator/'                                                                     
2024-03-03 21:08:35,524 | --base-dir is not presented, adjusting uri ./src/QhPonds.Tennis.LockCodeGenerator/ relative to /Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/template.yaml        
2024-03-03 21:08:35,529 | 1 resources found in the stack                                                                                                                                                             
2024-03-03 21:08:35,530 | Found Serverless function with name='LambdaEntryFunctionHandler' and CodeUri='./src/QhPonds.Tennis.LockCodeGenerator/'                                                                     
2024-03-03 21:08:35,532 | Instantiating build definitions                                                                                                                                                            
2024-03-03 21:08:35,537 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(dotnet8,                                                                                 
/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator, Zip, , 62382469-7097-4b93-851a-c21f9cb243de, {}, {}, x86_64, []), Function:                             
Function(function_id='LambdaEntryFunctionHandler', name='LambdaEntryFunctionHandler', functionname='LambdaEntryFunctionHandler', runtime='dotnet8', memory=None, timeout=10,                                         
handler='QhPonds.Tennis.LockCodeGenerator::QhPonds.Tennis.LockCodeGenerator.LambdaExecutor::LambdaEntryFunctionHandler', imageuri=None, packagetype='Zip', imageconfig=None,                                         
codeuri='/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator', environment={'Variables': {'PARAM1': 'VALUE'}}, rolearn=None, layers=[], events=None,         
metadata={'SamResourceId': 'LambdaEntryFunctionHandler'}, inlinecode=None, codesign_config_arn=None, architectures=None, function_url_config=None, function_build_info=<FunctionBuildInfo.BuildableZip:              
('BuildableZip', 'Regular ZIP function which can be build with SAM CLI')>, stack_path='', runtime_management_config=None, logging_config=None))                                                                      
2024-03-03 21:08:35,544 | Building codeuri: /Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator runtime: dotnet8 metadata: {} architecture: x86_64 functions:
LambdaEntryFunctionHandler                                                                                                                                                                                           
2024-03-03 21:08:35,545 | Building to following folder /Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/.aws-sam/build/LambdaEntryFunctionHandler                                              
2024-03-03 21:08:35,547 | Loading workflow module 'aws_lambda_builders.workflows'                                                                                                                                    
2024-03-03 21:08:35,550 | Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'                                            
2024-03-03 21:08:35,552 | Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'                               
2024-03-03 21:08:35,554 | Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'                                              
2024-03-03 21:08:35,557 | Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'                                           
2024-03-03 21:08:35,560 | Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'                                             
2024-03-03 21:08:35,563 | Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'                                              
2024-03-03 21:08:35,566 | Registering workflow 'NodejsNpmEsbuildBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)'                               
2024-03-03 21:08:35,569 | Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'                                              
2024-03-03 21:08:35,571 | Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'                                          
2024-03-03 21:08:35,573 | Registering workflow 'RustCargoLambdaBuilder' with capability 'Capability(language='rust', dependency_manager='cargo', application_framework=None)'                                        
2024-03-03 21:08:35,575 | Found workflow 'DotnetCliPackageBuilder' to support capabilities 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'                             
2024-03-03 21:08:35,576 | Workflow DotnetCliPackageBuilder does not support value "False" for building in source. Using default value "True".                                                                        
2024-03-03 21:08:35,577 | Running workflow 'DotnetCliPackageBuilder'                                                                                                                                                 
2024-03-03 21:08:35,578 |  Running DotnetCliPackageBuilder:GlobalToolInstall                                                                                                                                         
2024-03-03 21:08:35,579 | Entered synchronized block for updating Amazon.Lambda.Tools                                                                                                                                
2024-03-03 21:08:35,580 | Installing Amazon.Lambda.Tools Global Tool                                                                                                                                                 
2024-03-03 21:08:35,581 | executing dotnet: ['dotnet', 'tool', 'install', '-g', 'Amazon.Lambda.Tools', '--ignore-failed-sources']                                                                                    
2024-03-03 21:08:43,602 | Skipping NuGet package signature verification.                                                                                                                                             
Tools directory '/Users/mdasco/.dotnet/tools' is not currently on the PATH environment variable.                                                                                                                     
If you are using zsh, you can add it to your profile by running the following command:                                                                                                                               
                                                                                                                                                                                                                     
cat << \EOF >> ~/.zprofile                                                                                                                                                                                           
export PATH="$PATH:/Users/mdasco/.dotnet/tools"                                                                                                                                                                      
EOF                                                                                                                                                                                                                  
                                                                                                                                                                                                                    
And run `zsh -l` to make it available for current session.                                                                                                                                                           
                                                                                                                                                                                                                     
You can only add it to the current session by running the following command:                                                                                                                                         
                                                                                                                                                                                                                     
export PATH="$PATH:/Users/mdasco/.dotnet/tools"                                                                                                                                                                      
2024-03-03 21:08:43,607 | DotnetCliPackageBuilder:GlobalToolInstall succeeded                                                                                                                                        
2024-03-03 21:08:43,608 |  Running DotnetCliPackageBuilder:RunPackageAction                                                                                                                                          
2024-03-03 21:08:43,609 | Running `dotnet lambda package` in /Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator                                             
2024-03-03 21:08:43,610 | executing dotnet: ['dotnet', 'lambda', 'package', '--output-package',                                                                                                                      
'/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/.aws-sam/build/LambdaEntryFunctionHandler/QhPonds.Tennis.LockCodeGenerator.zip', '--function-architecture', 'x86_64', '--msbuild-parameters',
'--runtime linux-x64']                                                                                                                                                                                               
2024-03-03 21:08:45,887 | Amazon Lambda Tools for .NET Core applications (5.10.2)                                                                                                                                    
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet                                                                                                         
                                                                                                                                                                                                                     
Executing publish command                                                                                                                                                                                            
... invoking 'dotnet publish', working folder '/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator/bin/Release/net6.0/publish'                               
... dotnet publish "/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator" --output                                                                            
"/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator/bin/Release/net6.0/publish" --configuration "Release" --framework "net6.0" --runtime linux-x64          
/p:GenerateRuntimeConfigurationFiles=true --self-contained False                                                                                                                                                     
... publish: MSBuild version 17.9.4+90725d08d for .NET                                                                                                                                                               
... publish:   Determining projects to restore...                                                                                                                                                                    
... publish:   Restored /Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator/QhPonds.Tennis.LockCodeGenerator.csproj (in 242 ms).                             
... publish: /usr/local/share/dotnet/sdk/8.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1005: Assets file                                                  
'/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator/obj/project.assets.json' doesn't have a target for 'net6.0'. Ensure that restore has run and that you   
have included 'net6.0' in the TargetFrameworks for your project.                                                                                                                                                     
[/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator/QhPonds.Tennis.LockCodeGenerator.csproj]                                                                
ERROR: The dotnet publish command return unsuccessful error code                                                                                                                                                     
2024-03-03 21:08:45,893 | DotnetCliPackageBuilder:RunPackageAction failed                                                                                                                                            
Traceback (most recent call last):                                                                                                                                                                                   
  File "aws_lambda_builders/workflows/dotnet_clipackage/actions.py", line 133, in execute                                                                                                                            
  File "aws_lambda_builders/workflows/dotnet_clipackage/dotnetcli.py", line 65, 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 372, in run                                                                                                                                                           
  File "aws_lambda_builders/workflows/dotnet_clipackage/actions.py", line 140, in execute                                                                                                                            
aws_lambda_builders.actions.ActionFailedError: Dotnet CLI Failed:                                                                                                                                                    

Build Failed`

Observed result:

sam build fails - as per above

Offending line seems to be:

Executing publish command                                                                                                                                                                                            
... invoking 'dotnet publish', working folder '/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator/bin/Release/net6.0/publish'                               
... dotnet publish "/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator" --output                                                                            
"/Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator/bin/Release/net6.0/publish" --configuration "Release" --framework "net6.0" --runtime linux-x64          
/p:GenerateRuntimeConfigurationFiles=true --self-contained False  

Despite build settings defined correctly.

2024-03-03 21:08:35,544 | Building codeuri: /Users/mdasco/Desktop/Qhponds.Tennis/qhponds-tennis-lockcode-generator/src/QhPonds.Tennis.LockCodeGenerator runtime: dotnet8 metadata: {} architecture: x86_64 functions:
LambdaEntryFunctionHandler   

Expected result:

sam build should succeed

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

{
  "version": "1.110.0",
  "system": {
    "python": "3.8.13",
    "os": "macOS-14.2.1-x86_64-i386-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "Not available",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}
@mldasco mldasco added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Mar 3, 2024
@mldasco
Copy link
Author

mldasco commented Mar 3, 2024

Issue was with incorrectly configured aws-lambda.tools-defaults.json.

settings should be:

"framework" : "net8.0",
"function-runtime":"dotnet8",

@mldasco mldasco closed this as completed Mar 3, 2024
Copy link
Contributor

github-actions bot commented Mar 3, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.
Projects
None yet
Development

No branches or pull requests

1 participant