【发布时间】:2019-06-03 09:36:14
【问题描述】:
我已经设置了一个 IdentityServer4 服务器,如果我在主项目目录中执行 dotnet run,它就会运行,但如果我发布它然后尝试使用 dotnet 运行 dll,它就无法正常运行:
dotnet publish
cd bin/Debug/netcoreapp2.2/publish
dotnet MyIdentityServer.dll
我正在使用 ASP.Net Core 2.2。我已经在我的常规开发环境以及使用 SDK 和运行时 docker 容器中进行了尝试。它可以在我的常规环境和 SDK 容器中使用 SDK。在我的常规开发环境或运行时容器内部使用运行时时,它不起作用。
当我运行 dotnet 时,我可以看到 IdentityServer 的 Web UI,但是当我运行已发布的 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
我是发布不正确还是运行不正确?
【问题讨论】:
-
在 Dev 环境中尝试 dotnet run -c Release
-
您还需要帮助吗?
-
当我执行
dotnet run -c Release时,它使用的是项目目录中的 SDK,而不是使用发布目录中的运行时。在只有 dotnet 核心运行时的环境中,对dotnet run的任何调用都会失败。所以,是的,仍在寻找答案。更多信息在这里:docs.microsoft.com/en-us/dotnet/core/tools/… -
正在使用 AddDeveloperSigningCredential 可以添加 startup.cs
标签: identityserver4