我已经设置了一个IdentityServer4服务器,如果我在主项目目录中执行一个dotnet run
,它就会运行,但是如果我发布它,然后尝试用dotnet运行这个dll,它就不能正常运行:
dotnet publish
cd bin/Debug/netcoreapp2.2/publish
dotnet MyIdentityServer.dll
我使用的是ASP.Net核心2.2。我已经在我的常规开发环境中以及使用SDK和运行时docker容器进行了尝试。它在我的常规环境和SDK容器中都可以使用SDK。无论是在我的常规开发环境中还是在运行时容器中使用运行时,它都不起作用。
当我运行dotnet时,我可以看到IdentityServer的web用户界面,但是当我运行发布的DLL时,启动没有相同的IdentityServer启动消息,并且在它显示它正在运行之后,我无法在它说应该运行的端口上连接到服务器。
下面是在执行dotnet run
后启动消息的外观
MacBook-Pro:MyIdentityServer XXXXXXXXXX$ dotnet run
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/Users/XXXXXXXXXX/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
info: IdentityServer4.Startup[0]
Starting IdentityServer4 version 2.3.2.0
info: IdentityServer4.Startup[0]
You are using the in-memory version of the persisted grant store. This will store consent decisions, authorization codes, refresh and reference tokens in memory only. If you are using any of those features in production, you want to switch to a different store implementation.
info: IdentityServer4.Startup[0]
Using the default authentication scheme idsrv for IdentityServer
dbug: IdentityServer4.Startup[0]
Using idsrv as default ASP.NET Core scheme for authentication
dbug: IdentityServer4.Startup[0]
Using idsrv as default ASP.NET Core scheme for sign-in
dbug: IdentityServer4.Startup[0]
Using idsrv as default ASP.NET Core scheme for sign-out
dbug: IdentityServer4.Startup[0]
Using idsrv as default ASP.NET Core scheme for challenge
dbug: IdentityServer4.Startup[0]
Using idsrv as default ASP.NET Core scheme for forbid
Hosting environment: Development
Content root path: /Users/XXXXXXXXXX/Projects/FirstIdentityServer4/src/MyIdentityServer
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
下面是在使用dotnet MyIdentityServer.dll
直接运行已发布的DLL后,当它不工作时的启动消息
MacBook-Pro:publish XXXXXXXXXXXX$ dotnet MyIdentityServer.dll
Hosting environment: Production
Content root path: /Users/XXXXXXXXXXX/Projects/FirstIdentityServer4/src/MyIdentityServer/bin/Debug/netcoreapp2.2/publish
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
下面是我的项目目录:
MacBook-Pro:MyIdentityServer XXXXXXXXX$ ls
Config.cs appsettings.Development.json
Dockerfile appsettings.json
MyIdentityServer.csproj bin
Program.cs obj
Properties something.txt
Quickstart tempkey.rsa
Startup.cs wwwroot
Views
下面是我在执行dotnet publish
之后的发布目录
MacBook-Pro:publish XXXXXXXXXX$ ls
IdentityModel.dll MyIdentityServer.pdb
IdentityServer4.Storage.dll MyIdentityServer.runtimeconfig.json
IdentityServer4.dll appsettings.Development.json
MyIdentityServer.Views.dll appsettings.json
MyIdentityServer.Views.pdb tempkey.rsa
MyIdentityServer.deps.json web.config
MyIdentityServer.dll wwwroot
是我错误地发布它还是错误地运行它?
发布于 2019-01-10 17:51:40
基于
MacBook-Pro:MyIdentityServer XXXXXXXXXX$ dotnet run
dbug: IdentityServer4.Startup[0]
Using idsrv as default ASP.NET Core scheme for forbid
Hosting environment: Development
还有这个
MacBook-Pro:publish XXXXXXXXXXXX$ dotnet MyIdentityServer.dll
Hosting environment: Production
日志
dbug: IdentityServer4.Startup[0]
通常来自
services.AddIdentityServer();
所以我很高兴你在IsDevelopment内部调用AddIdentityServer
if (Environment.IsDevelopment())
{
services.AddIdentityServer();
}
这就是为什么托管环境:生产无法获取IdentityServer日志的原因
https://stackoverflow.com/questions/54096111
复制相似问题