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 with project references in adjacent directory (.NET8 NativeAOT) #7321

Closed
kyl3t opened this issue Aug 6, 2024 · 4 comments
Closed
Labels
stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Comments

@kyl3t
Copy link

kyl3t commented Aug 6, 2024

Hi,
I have a question regarding running sam build on a .NET 8 Serverless NativeAOT project with project references referencing an adjacent directory.

My project structure is as below, building worked fine when building only the Cwoc.Lambda project but ever since including shared projects from the shared folder, the docker run command that is eventually called is not able to locate these files as they aren't mounted.

Please let me know of any workarounds or options to address this.
Thanks

.
└── src/
    ├── apps/
    │   └── Cwoc/
    │       ├── Cwoc.sln
    │       └── Cwoc.Lambda/
    │           ├── serverless.yaml
    │           └── ...
    └── shared/
        ├── CA.C7.API
        ├── CA.Email
        └── ...
sam build --template ./apps/Cwoc/Cwoc.Lambda/serverless.yaml
Building codeuri: /Users/kt/Source/custom/src/apps/Cwoc/Cwoc.Lambda runtime: dotnet8 metadata: {'Tool': 'Amazon.Lambda.Annotations'} architecture: arm64 functions:                                              
CwocLambdaFunctionsOrderTxHandlerGenerated, CwocLambdaFunctionsOrderRxHandlerGenerated, CwocLambdaFunctionsStockSyncHandlerGenerated                                                                  
Workflow DotnetCliPackageBuilder does not support value "False" for building in source. Using default value "True".                                                                                                                                                     
 Running DotnetCliPackageBuilder:GlobalToolInstall                                                                                                                                                                                                                      
Tool 'amazon.lambda.tools' was reinstalled with the stable version (version '5.10.7').                                                                                                                                                                                  
 Running DotnetCliPackageBuilder:RunPackageAction                                                                                                                                                                                                                       
Amazon Lambda Tools for .NET Core applications (5.10.7)                                                                                                                                                                                                                 
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet                                                                                                                                                            
                                                                                                                                                                                                                                                                        
Executing publish command                                                                                                                                                                                                                                               
Starting container for native AOT build using build image: public.ecr.aws/sam/build-dotnet8:latest-arm64.                                                                                                                                                               
... invoking 'docker run --name tempLambdaBuildContainer-6e26ef82-2544-427d-83cd-b3d780edf5e1 --rm --volume "/Users/kt/Source/custom/src/apps/Cwoc":/tmp/source/ -i -u 501:20 -e DOTNET_CLI_HOME=/tmp/dotnet -e XDG_DATA_HOME=/tmp/xdg 
public.ecr.aws/sam/build-dotnet8:latest-arm64 dotnet publish "/tmp/source/Cwoc.Lambda" --output "/tmp/source/Cwoc.Lambda/bin/Release/net8.0/publish" --configuration "Release" --framework "net8.0" --runtime linux-arm64   
/p:GenerateRuntimeConfigurationFiles=true --self-contained True  /p:StripSymbols=true' from directory /Users/kt/Source/custom/src/apps/Cwoc                                                                                            
... 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 "/shared/CA.C7.API/CA.C7.API.csproj" because it was not found.                                                                                                                                                   
... docker run:   Skipping project "/shared/CA.Protocols.SFTP/CA.Protocols.SFTP.csproj" because it was not found.                                                                                                                                       
... docker run:   Skipping project "/shared/CA.C7.API/CA.C7.API.csproj" because it was not found.                                                                                                                                                   
... docker run:   Skipping project "/shared/CA.Protocols.SFTP/CA.Protocols.SFTP.csproj" because it was not found.                                                                                                                                       
... docker run:   Restored /tmp/source/Cwoc/Cwoc.csproj (in 4.07 sec).                                                                                                                                                      
... docker run:   Restored /tmp/source/Cwoc.Lambda/Cwoc.Lambda.csproj (in 8.59 sec).                                                                                                                                        
... docker run: /var/lang/bin/sdk/8.0.303/Microsoft.Common.CurrentVersion.targets(2165,5): warning : The referenced project '../../../shared/CA.C7.API/CA.C7.API.csproj' does not exist.                                                            
[/tmp/source/Cwoc/Cwoc.csproj]                                                                                                                                                                                              
... docker run: /var/lang/bin/sdk/8.0.303/Microsoft.Common.CurrentVersion.targets(2165,5): warning : The referenced project '../../../shared/CA.Protocols.SFTP/CA.Protocols.SFTP.csproj' does not exist.                                                
[/tmp/source/Cwoc/Cwoc.csproj]                                                                                                                                                                                              
... docker run: /tmp/source/Cwoc/Di.cs(4,7): error CS0246: The type or namespace name 'CA' could not be found (are you missing a using directive or an assembly reference?)                                                               
[/tmp/source/Cwoc/Cwoc.csproj]                                                                                                                                                                                              
... docker run: /tmp/source/Cwoc/Di.cs(5,7): error CS0246: The type or namespace name 'CA' could not be found (are you missing a using directive or an assembly reference?)                                                               
[/tmp/source/Cwoc/Cwoc.csproj]                                                                                                                                                                                              
... docker run: /tmp/source/Cwoc/Handlers/OrderRxHandler.cs(4,7): error CS0246: The type or namespace name 'CA' could not be found (are you missing a using directive or an assembly reference?)                                          
[/tmp/source/Cwoc/Cwoc.csproj]                                                                                                                                                                                              
... docker run: /tmp/source/Cwoc/Handlers/OrderRxHandler.cs(5,7): error CS0246: The type or namespace name 'CA' could not be found (are you missing a using directive or an assembly reference?)                                          
[/tmp/source/Cwoc/Cwoc.csproj]                                                                                                                                                                                              
... docker run: /tmp/source/Cwoc/Handlers/OrderRxHandler.cs(6,7): error CS0246: The type or namespace name 'CA' could not be found (are you missing a using directive or an assembly reference?)                                          
[/tmp/source/Cwoc/Cwoc.csproj]                                                                                                                                                                                              
... docker run: /tmp/source/Cwoc/Handlers/OrderTxHandler.cs(3,7): error CS0246: The type or namespace name 'CA' could not be found (are you missing a using directive or an assembly reference?)                                          
[/tmp/source/Cwoc/Cwoc.csproj]                                                                                                                                                                                              
...                          
[/tmp/source/Cwoc/Cwoc.csproj]                                                                                                                                                                                              
ERROR: Container build returned 1                                                                                                                                                                                                                                       

Build Failed
Error: DotnetCliPackageBuild
@kyl3t kyl3t added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Aug 6, 2024
@Beau-Gosse-dev
Copy link
Contributor

Related: aws/aws-extensions-for-dotnet-cli#332

@kyl3t
Copy link
Author

kyl3t commented Aug 7, 2024

As mentioned by @normj in this discussion - "code-mount-directory" can be set in the aws-lambda-tools-defaults.json to reference a path that the dotnet lambda command eventually uses.

@mndeveci
Copy link
Contributor

mndeveci commented Aug 7, 2024

Resolving this issue assuming this is already resolved in the other thread above. Please let us know if you have any other questions.

@mndeveci mndeveci closed this as completed Aug 7, 2024
Copy link
Contributor

github-actions bot commented Aug 7, 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

3 participants