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

The --msbuild-parameters flag is performing incorrectly when spawned by child_process #1922

Closed
1 task
Levelleor opened this issue Dec 30, 2024 · 2 comments
Closed
1 task
Assignees
Labels
bug This issue is a bug. module/lambda-client-lib p2 This is a standard priority issue s Effort estimation: small

Comments

@Levelleor
Copy link

Levelleor commented Dec 30, 2024

Describe the bug

This is a duplicate of aws/aws-extensions-for-dotnet-cli#358, I just thought this might be a better place for the issue. Feel free to close either of these to avoid duplicates.

I am executing the following command via a JS Github Action:

dotnet lambda package --disable-interactive True --project-location /sources/dotnet/lambda/src --output-package publish/output.zip --function-runtime dotnet8 --function-architecture arm64 --msbuild-parameters "--no-restore --no-build"

I need the ability to pass multiple arguments via msbuild-parameters flag and thus I've encapsulated them into double quotes as requested by the help manual. Both --no-restore and --no-build here are appended as a single command-line argument and are not parsed by dotnet correctly, instead being set on MSBuild call and failing the execution.

A minimal example looks like this:
https://github.com/Levelleor/test-net-lambda-tool/blob/main/.github/workflows/ci.yaml
Here is an unsuccessful execution:
https://github.com/Levelleor/test-net-lambda-tool/actions/runs/12511014146/job/34902532872#step:5:30
It tries to run this command:
/usr/share/dotnet/dotnet lambda package --output-package package.zip --msbuild-parameters "--no-restore --no-build"
But fails with this error:

 /usr/share/dotnet/dotnet lambda package --output-package package.zip --msbuild-parameters "--no-restore --no-build"
Amazon Lambda Tools for .NET Core applications (5.12.3)
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 '/home/runner/work/test-net-lambda-tool/test-net-lambda-tool/bin/Release/net8.0/publish'
... dotnet publish "/home/runner/work/test-net-lambda-tool/test-net-lambda-tool" --output "/home/runner/work/test-net-lambda-tool/test-net-lambda-tool/bin/Release/net8.0/publish" --configuration "Release" --framework "net8.0" "--no-restore --no-build" /p:GenerateRuntimeConfigurationFiles=true --runtime linux-x64 --self-contained False 
... publish: MSBUILD : error MSB1001: Unknown switch.
... publish:     Full command line: '/usr/share/dotnet/sdk/8.0.404/MSBuild.dll -maxcpucount -verbosity:m -nologo -target:Restore --property:_IsPublishing=true --property:GenerateRuntimeConfigurationFiles=true -property:PublishDir=/home/runner/work/test-net-lambda-tool/test-net-lambda-tool/bin/Release/net8.0/publish -property:_CommandLineDefinedOutputPath=true -property:SelfContained=False -property:_CommandLineDefinedSelfContained=true -property:RuntimeIdentifier=linux-x64 -property:_CommandLineDefinedRuntimeIdentifier=true -property:Configuration=Release -property:DOTNET_CLI_DISABLE_PUBLISH_AND_PACK_RELEASE=true /home/runner/work/test-net-lambda-tool/test-net-lambda-tool --no-restore --no-build -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/usr/share/dotnet/sdk/8.0.404/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/usr/share/dotnet/sdk/8.0.404/dotnet.dll'
... publish:   Switches appended by response files:
... publish: Switch: --no-restore --no-build
... publish: For switch syntax, type "MSBuild -help"
ERROR: The dotnet publish command return unsuccessful error code
Error: The process '/usr/share/dotnet/dotnet' failed with exit code 255

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

I expect this to be called:

dotnet publish "/sources/dotnet/lambda/src" --output "/sources/dotnet/lambda/src/bin/Release/net8.0/publish" --configuration "Release" --framework "net8.0" --no-restore --no-build /p:GenerateRuntimeConfigurationFiles=true --runtime linux-arm64 --self-contained False 

Current Behavior

I get this result instead:

dotnet publish "/sources/dotnet/lambda/src" --output "/sources/dotnet/lambda/src/bin/Release/net8.0/publish" --configuration "Release" --framework "net8.0" "--no-restore --no-build" /p:GenerateRuntimeConfigurationFiles=true --runtime linux-arm64 --self-contained False 

.NET isn't parsing --no-restore and --no-build because it didn't recognize them and thus it passed these down to msbuild it seems like.

... publish: MSBUILD : error MSB1001: Unknown switch.
... publish:     Full command line: 'MSBuild.dll -maxcpucount -verbosity:m -nologo -target:Restore --property:_IsPublishing=true --property:GenerateRuntimeConfigurationFiles=true -property:PublishDir=/sources/dotnet/lambda/src/bin/Release/net8.0/publish -property:_CommandLineDefinedOutputPath=true -property:SelfContained=False -property:_CommandLineDefinedSelfContained=true -property:RuntimeIdentifier=linux-arm64 -property:_CommandLineDefinedRuntimeIdentifier=true -property:Configuration=Release -property:DOTNET_CLI_DISABLE_PUBLISH_AND_PACK_RELEASE=true /sources/dotnet/lambda/src --no-restore --no-build -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/.dotnet/sdk/8.0.404/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/.dotnet/sdk/8.0.404/dotnet.dll'
... publish:   Switches appended by response files:
... publish: Switch: --no-restore --no-build
... publish: For switch syntax, type "MSBuild -help"
ERROR: The dotnet publish command return unsuccessful error code

Reproduction Steps

Try invoking the lambda tool via JS while setting multiple msbuild parameters.
A minimal example looks like this:
https://github.com/Levelleor/test-net-lambda-tool/blob/main/.github/workflows/ci.yaml
Here is an unsuccessful execution:
https://github.com/Levelleor/test-net-lambda-tool/actions/runs/12511014146/job/34902532872#step:5:30

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Package Id Version Commands

amazon.lambda.tools 5.12.3 dotnet-lambda

Targeted .NET Platform

.NET 8

Operating System and version

RHEL9

@Levelleor Levelleor added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 30, 2024
@ashishdhingra ashishdhingra self-assigned this Dec 30, 2024
@ashishdhingra ashishdhingra added p2 This is a standard priority issue module/lambda-client-lib s Effort estimation: small and removed needs-triage This issue or PR still needs to be triaged. labels Dec 30, 2024
@ashishdhingra
Copy link
Contributor

Duplicate of aws/aws-extensions-for-dotnet-cli#358. The issue is related to .NET Extensions for CLI tooling.

Copy link
Contributor

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
bug This issue is a bug. module/lambda-client-lib p2 This is a standard priority issue s Effort estimation: small
Projects
None yet
Development

No branches or pull requests

2 participants