aws / aws-extensions-for-dotnet-cli

Extensions to the dotnet CLI to simplify the process of building and publishing .NET Core applications to AWS services
Apache License 2.0
369 stars 86 forks source link

Self-Contained property in csproj file is ignored #270

Closed Beau-Gosse-dev closed 1 year ago

Beau-Gosse-dev commented 1 year ago

Describe the bug

If you set self-contained in the csproj file, the code here ignores it and only looks at msbuild parameters passed through the CLI. This is a problem when using SAM CLI, since they don't provide a way to pass msbuild parameters through the CLI call to Amazon.Lambda.Tools.

Expected Behavior

If self-contained is set to true, and publish aot is false (both in the csproj file), the app should still publish as self-contained.

Current Behavior

Because publish aot is false, self-contained defaults to false

Reproduction Steps

dotnet new lambda.CustomRuntimeFunction

Remove "msbuild-parameters": "--self-contained true" from aws-lambda-tools-defaults.json

Add <SelfContained>true</SelfContained> to csproj file

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <SelfContained>true</SelfContained>
  </PropertyGroup>

</Project>

Or a more realistic example would be to try and publish a non-native AOT .NET 7 custom runtime function using SAM CLI.

Possible Solution

https://github.com/aws/aws-extensions-for-dotnet-cli/pull/271

Additional Information/Context

No response

Targeted .NET platform

.NET 7 custom runtime

CLI extension version

amazon.lambda.tools 5.6.3 dotnet-lambda

Environment details (OS name and version, etc.)

windows 10

ashishdhingra commented 1 year ago

Change has been released in Amazon.Lambda.Tools version 5.6.5.

github-actions[bot] commented 1 year ago

⚠️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.