Skip to content

Commit 446deaa

Browse files
fix service issue
1 parent 71756ff commit 446deaa

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

SecurityService/Program.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@
3838
using NLog.Extensions.Logging;
3939
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
4040

41-
var builder = WebApplication.CreateBuilder(args);
41+
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
42+
{
43+
Args = args,
44+
ContentRootPath = AppContext.BaseDirectory
45+
});
46+
builder.Host.UseWindowsService();
4247

4348
builder.WebHost.ConfigureAppConfiguration((context, configBuilder) =>
4449
{
@@ -285,7 +290,7 @@
285290
validationOptions.UseAspNetCore();
286291
});
287292

288-
String contentRoot = Directory.GetCurrentDirectory();
293+
String contentRoot = builder.Environment.ContentRootPath;
289294
String nlogConfigPath = Path.Combine(contentRoot, "nlog.config");
290295

291296
LogManager.Setup(b =>

SecurityService/SecurityService.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.5" />
2323
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="10.0.5" />
2424
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.5" />
25+
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.5" />
2526
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.5">
2627
<PrivateAssets>all</PrivateAssets>
2728
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -46,6 +47,9 @@
4647
<ProjectReference Include="..\SecurityService.Models\SecurityService.Models.csproj" />
4748
</ItemGroup>
4849
<ItemGroup>
50+
<Content Update="appsettings.staging.json">
51+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
52+
</Content>
4953
<Content Update="appsettings.json">
5054
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
5155
</Content>

SecurityService/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
},
55
"ServiceOptions": {
66
"SeedDefaultScopes": false,
7-
"PublicOrigin": "https://127.0.0.1:50001",
7+
"PublicOrigin": "https://127.0.0.1:5001",
88
"IssuerUrl": "https://127.0.0.1:5001",
99
"ClientId": "serviceClient",
1010
"ClientSecret": "d192cbc46d834d0da90e8a9d50ded543",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ServiceOptions": {
3+
"PublicOrigin": "https://192.168.1.163:5001",
4+
"IssuerUrl": "https://192.168.1.163:5001"
5+
},
6+
"ConnectionStrings": {
7+
"AuthenticationDbContext": "server=127.0.0.1;database=SecurityService;user id=sa;password=Sc0tland;Encrypt=false"
8+
}
9+
}

0 commit comments

Comments
 (0)