Как я могу создать все файлы удостоверений в проекте ASP.NET Core 2.1 MVC через dotnet? - PullRequest
0 голосов
/ 07 сентября 2018

В статье MSDN, озаглавленной Идентификация скаффолда в проектах ASP.NET Core , есть набор инструкций специально для "создание источника пользовательского интерфейса с полной идентификацией" ( вместо использования Razor Class Library для идентификации ).

Этот раздел начинается с:

Чтобы обеспечить полный контроль над пользовательским интерфейсом Identity, запустите скаффолдер Identity и выберите Переопределить все файлы.

Не дано ни одной команды, которая может быть запущена в оболочке, чтобы создать все эти файлы, поэтому я предполагаю, что «переопределить все файлы» - это элемент управления пользовательского интерфейса в Visual Studio.

Если мы посмотрим на вывод dotnet aspnet-codegenerator identity -h, мы не увидим никакой опции для генерации всех файлов.

Usage: aspnet-codegenerator [arguments] [options]

Arguments:
  generator  Name of the generator. Check available generators below.

Options:
  -p|--project             Path to .csproj file in the project.
  -n|--nuget-package-dir   
  -c|--configuration       Configuration for the project (Possible values: Debug/ Release)
  -tfm|--target-framework  Target Framework to use. (Short folder name of the tfm. eg. net46)
  -b|--build-base-path     
  --no-build               

Selected Code Generator: identity

Generator Options:
  --dbContext|-dc      : Name of the DbContext to use, or generate (if it does not exist).
  --files|-fi          : List of semicolon separated files to scaffold. Use the --list-files option to see the available options.
  --listFiles|-lf      : Lists the files that can be scaffolded by using the '--files' option.
  --userClass|-u       : Name of the User class to generate.
  --useSqLite|-sqlite  : Flag to specify if DbContext should use SQLite instead of SQL Server.
  --force|-f           : Use this option to overwrite existing files.
  --useDefaultUI|-udui : Use this option to setup identity and to use Default UI.
  --layout|-l          : Specify a custom layout file to use.
  --generateLayout|-gl : Use this option to generate a new _Layout.cshtml

Учитывая все это, как пользователи инструмента dotnet для создания леса командной строки могут генерировать все файлов, которые являются частью генератора идентификаторов?

Ответы [ 2 ]

0 голосов
/ 01 февраля 2019

Если вы опустите флажки --files и --useDefaultUI, будут сгенерированы все файлы.

$ dotnet aspnet-codegenerator identity

По документам :

Если вы запускаете скаффолдер Identity без указания --files флаг или флаг --useDefaultUI, все доступные страницы интерфейса пользователя. будет создан в вашем проекте.


Источники:

https://github.com/aspnet/Docs/pull/8752

0 голосов
/ 07 сентября 2018

Как уже отмечалось, в настоящее время нет опции командной строки для генерации всех файлов идентификации.

К счастью, опции --files и --listFiles могут использоваться вместе для достижения этой цели.

Шаг 1: список файлов, которые могут быть добавлены в леса

$ dotnet aspnet-codegenerator identity --listFiles
Building project ...
Finding the generator 'identity'...
Running the generator 'identity'...
File List:
Account.AccessDenied
Account.ConfirmEmail
Account.ExternalLogin
Account.ForgotPassword
Account.ForgotPasswordConfirmation
Account.Lockout
Account.Login
Account.LoginWith2fa
Account.LoginWithRecoveryCode
Account.Logout
Account.Manage._Layout
Account.Manage._ManageNav
Account.Manage._StatusMessage
Account.Manage.ChangePassword
Account.Manage.DeletePersonalData
Account.Manage.Disable2fa
Account.Manage.DownloadPersonalData
Account.Manage.EnableAuthenticator
Account.Manage.ExternalLogins
Account.Manage.GenerateRecoveryCodes
Account.Manage.Index
Account.Manage.PersonalData
Account.Manage.ResetAuthenticator
Account.Manage.SetPassword
Account.Manage.TwoFactorAuthentication
Account.Register
Account.ResetPassword
Account.ResetPasswordConfirmation

Нам нужны все строки после «Список файлов:».

Шаг 2: объединить эти имена в строку, разделенную точкой с запятой

Account.AccessDenied;Account.ConfirmEmail;Account.ExternalLogin;Account.ForgotPassword;Account.ForgotPasswordConfirmation;Account.Lockout;Account.Login;Account.LoginWith2fa;Account.LoginWithRecoveryCode;Account.Logout;Account.Manage._Layout;Account.Manage._ManageNav;Account.Manage._StatusMessage;Account.Manage.ChangePassword;Account.Manage.DeletePersonalData;Account.Manage.Disable2fa;Account.Manage.DownloadPersonalData;Account.Manage.EnableAuthenticator;Account.Manage.ExternalLogins;Account.Manage.GenerateRecoveryCodes;Account.Manage.Index;Account.Manage.PersonalData;Account.Manage.ResetAuthenticator;Account.Manage.SetPassword;Account.Manage.TwoFactorAuthentication;Account.Register;Account.ResetPassword;Account.ResetPasswordConfirmation

Шаг 3: На этот раз снова запустите генератор, задав опцию --files строку, которую мы только что создали

Мы не можем забыть заключить в кавычки , или наша оболочка может попытаться выполнить эти имена файлов как команды (потому что ; является терминатором команды).

$ dotnet aspnet-codegenerator identity --files="Account.AccessDenied;Account.ConfirmEmail;Account.ExternalLogin;Account.ForgotPassword;Account.ForgotPasswordConfirmation;Account.Lockout;Account.Login;Account.LoginWith2fa;Account.LoginWithRecoveryCode;Account.Logout;Account.Manage._Layout;Account.Manage._ManageNav;Account.Manage._StatusMessage;Account.Manage.ChangePassword;Account.Manage.DeletePersonalData;Account.Manage.Disable2fa;Account.Manage.DownloadPersonalData;Account.Manage.EnableAuthenticator;Account.Manage.ExternalLogins;Account.Manage.GenerateRecoveryCodes;Account.Manage.Index;Account.Manage.PersonalData;Account.Manage.ResetAuthenticator;Account.Manage.SetPassword;Account.Manage.TwoFactorAuthentication;Account.Register;Account.ResetPassword;Account.ResetPasswordConfirmation"

Предполагая, что выполнено успешно, теперь у нас есть весь код идентификации (внутренний код, пользовательский интерфейс и т. Д.) Непосредственно в нашем исходном дереве.


Ссылки:

https://github.com/aspnet/Docs/issues/8443

https://github.com/aspnet/Scaffolding/issues/872

...