aspnet / Templating

[Archived] ASP.NET Core templates for .NET CLI and Visual Studio. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
205 stars 79 forks source link

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

Closed livarcocc closed 6 years ago

livarcocc commented 6 years ago

From @WingedDante on May 31, 2018 19:55

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]

Copied from original issue: dotnet/cli#9387

natemcmaster commented 6 years ago

@mkArtakMSFT @ryanbrandenburg PTAL

mkArtakMSFT commented 6 years ago

@javiercn, can you please look into this?

javiercn commented 6 years ago

I do believe that this is controlled simply by the --no-https option and that Auth doesn't play a role in it at the templates level. I do believe VS has some logic around auth and HTTPS, but that's it. I don't think it matters that much either as we changed the redirection middleware after preview2 to NOOP if it can't figure out an HTTPS port to redirect to.

I would just close this as by design. See https://github.com/aspnet/templating/commit/cb7942abe41eebbbe574c515b171e6bb9f48fbdd for the original change

mkArtakMSFT commented 6 years ago

Hi @WingedDante. Can you please share the link of the docs you've read about the auth configuration using --au option? This is more of a docs issue, which would be great to fix.

WingedDante commented 6 years ago

Sure, the documentation I was looking at for the dotnet new command was here. I had just assumed it was from the -au flag because there wasn't a --no-https listed as either one of the base dotnet new options, nor one of the template specific ones, and I saw parts of the changes @javiercn mentioned. I did try it with the --no-https option and did get the expected output. Adding in something about the --no-https option would definitely be helpful. Thanks everyone.

mkArtakMSFT commented 6 years ago

@javiercn, can you please take care of getting the docs updated to mention about no-https option. Thanks!

javiercn commented 6 years ago

@Rick-Anderson Can you take care of this?

mkArtakMSFT commented 6 years ago

Closing this in favor of the referenced docs bug: https://github.com/aspnet/Docs/issues/6923