aws-lambda-dotnet icon indicating copy to clipboard operation
aws-lambda-dotnet copied to clipboard

`dotnet new` generates project in src folder

Open Swimburger opened this issue 3 years ago • 6 comments

Describe the bug

dotnet new generates project in src folder, handling the --name and --output parameter incorrectly.

Let's use the following command as example 1:

dotnet new serverless.AspNetCoreMinimalAPI --name MyLambdaMinimalApi --output .

And the following as example 2:

dotnet new serverless.AspNetCoreMinimalAPI --name MyLambdaMinimalApi --output MyFolder

Expected Behavior

1: The expected result would be to generate the project files in the current folder because --output ., but the project name should be MyLambdaMinimalApi.csproj. 2: The expected result would be a folder MyFolder with the project files in it including the MyLambdaMinimalApi.csproj project file.

Current Behavior

1: The actual result is an src folder with a MyLambdaMinimalApi subfolder, with the project files in it. 2: The actual result is a MyFolder folder with a src subfolder, with a MyLambdaMinimalApi subfolder, with the project files in it.

Reproduction Steps

(Commands above)

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Lambda templates 6.2.0

Targeted .NET Platform

.NET 6

Operating System and version

macOS 12.5

Swimburger avatar Aug 09 '22 02:08 Swimburger

Hi @Swimburger,

Thanks for reporting the issue. The output of the dotnet new serverless.AspNetCoreMinimalAPI --name MyLambdaMinimalApi --output . command is controlled by the Lambda Blueprint template which defines the top level structure with src as parent folder. The --output parameter specified the location to place the generated output and is controlled by the .NET CLI.

Thanks, Ashish

ashishdhingra avatar Aug 09 '22 16:08 ashishdhingra

If I understand correctly, the --name and --output argument is handled by .NET CLI (not part of this project), but it's the src folder that is injected by the AWS templates? Should /src be removed from template.json to make it consistent with other project templates?

Swimburger avatar Aug 09 '22 20:08 Swimburger

If I understand correctly, the --name and --output argument is handled by .NET CLI (not part of this project), but it's the src folder that is injected by the AWS templates? Should /src be removed from template.json to make it consistent with other project templates?

@Swimburger This needs discussion with the team.

ashishdhingra avatar Aug 09 '22 20:08 ashishdhingra

Marking this as feature request since this is working as designed. May be we could include a switch which controls the creation of test folder. If not we default to the user's scenario.

ashishdhingra avatar Aug 26 '22 20:08 ashishdhingra

I'm not aware of a test folder. I want project templates to behave like the default .NET SDK project templates.

Swimburger avatar Aug 26 '22 20:08 Swimburger

Related GitHub issue https://github.com/aws/aws-lambda-dotnet/issues/1412

ashishdhingra avatar Mar 03 '23 18:03 ashishdhingra