dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.67k stars 1.06k forks source link

dotnet new webapi ignoring -au flag for template generation #9445

Closed WingedDante closed 4 years ago

WingedDante commented 6 years ago

Steps to reproduce

Ensure you're on 2.1.300

Run dotnet new webapi -n="example"

Examine Startup.cs in the example project folder.

As far as I'm aware and can find in the docs, and looking through the template code, the UseHsts and UseHttpsRedirection are only supposed to be output if the -au(--auth) flag is set, and it's supposed to default to none if one isn't supplied. Unless this functionality has changed.

Expected behavior

Creates a new webapi project from template with no SSL created in Startup.cs.

Actual behavior

Creates a new webapi project from template with SSL created in Startup.cs, ignoring the default 'None' value for the auth flag.
These lines are added

else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();

I compared with the older sdk using a global json setting it to 2.0.3, and the webapi project was created correctly.

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.300
 Commit:    adab45bf0c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.300\

Host (useful for support):
  Version: 2.1.0
  Commit:  caa7b7e2ba

.NET Core SDKs installed:
  2.0.3 [C:\Program Files\dotnet\sdk]
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.102 [C:\Program Files\dotnet\sdk]
  2.1.103 [C:\Program Files\dotnet\sdk]
  2.1.300 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
livarcocc commented 6 years ago

This issue was moved to aspnet/templating#548