Compare commits
2 Commits
15241429fc
...
c63a48af6e
Author | SHA1 | Date |
---|---|---|
Tudor Stanciu | c63a48af6e | |
Tudor Stanciu | 06c76f5745 |
|
@ -6,6 +6,8 @@ using NetworkResurrector.Agent.Extensions;
|
|||
using NetworkResurrector.Agent.Extensions.Serilog;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace NetworkResurrector.Agent
|
||||
{
|
||||
|
@ -13,7 +15,24 @@ namespace NetworkResurrector.Agent
|
|||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var isConsole = Debugger.IsAttached || args.Contains("--console");
|
||||
|
||||
WebApplicationBuilder builder;
|
||||
if (isConsole)
|
||||
{
|
||||
builder = WebApplication.CreateBuilder(args);
|
||||
}
|
||||
else
|
||||
{
|
||||
var webApplicationOptions = new WebApplicationOptions()
|
||||
{
|
||||
ContentRootPath = AppContext.BaseDirectory,
|
||||
Args = args,
|
||||
ApplicationName = Process.GetCurrentProcess().ProcessName
|
||||
};
|
||||
builder = WebApplication.CreateBuilder(webApplicationOptions);
|
||||
builder.Host.UseWindowsService();
|
||||
}
|
||||
|
||||
builder.Host.UseSerilog((_, lc) =>
|
||||
{
|
||||
|
@ -27,10 +46,6 @@ namespace NetworkResurrector.Agent
|
|||
|
||||
builder.Services.ConfigureServices(builder.Configuration);
|
||||
|
||||
var useWindowsService = builder.Configuration.GetValue<bool>("Host:UseWindowsService");
|
||||
if (useWindowsService)
|
||||
builder.Host.UseWindowsService();
|
||||
|
||||
var app = builder.Build();
|
||||
app.Configure(builder.Configuration);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>false</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
|
@ -10,7 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Release\net5.0\publish\</PublishUrl>
|
||||
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
"ConnectionStrings": {
|
||||
"DatabaseConnection": "Server=#########;Database=#########;User Id=#########;Password=#########;MultipleActiveResultSets=true"
|
||||
},
|
||||
"Host": {
|
||||
"UseWindowsService": true
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
|
|
|
@ -5,6 +5,8 @@ using Microsoft.Extensions.Hosting;
|
|||
using NetworkResurrector.Server.Extensions;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace NetworkResurrector.Server
|
||||
{
|
||||
|
@ -12,7 +14,24 @@ namespace NetworkResurrector.Server
|
|||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var isConsole = Debugger.IsAttached || args.Contains("--console");
|
||||
|
||||
WebApplicationBuilder builder;
|
||||
if (isConsole)
|
||||
{
|
||||
builder = WebApplication.CreateBuilder(args);
|
||||
}
|
||||
else
|
||||
{
|
||||
var webApplicationOptions = new WebApplicationOptions()
|
||||
{
|
||||
ContentRootPath = AppContext.BaseDirectory,
|
||||
Args = args,
|
||||
ApplicationName = Process.GetCurrentProcess().ProcessName
|
||||
};
|
||||
builder = WebApplication.CreateBuilder(webApplicationOptions);
|
||||
builder.Host.UseWindowsService();
|
||||
}
|
||||
|
||||
builder.Host.UseSerilog((_, lc) =>
|
||||
{
|
||||
|
@ -24,11 +43,6 @@ namespace NetworkResurrector.Server
|
|||
});
|
||||
|
||||
builder.Services.ConfigureServices(builder.Configuration);
|
||||
|
||||
var useWindowsService = builder.Configuration.GetValue<bool>("Host:UseWindowsService");
|
||||
if (useWindowsService)
|
||||
builder.Host.UseWindowsService();
|
||||
|
||||
var app = builder.Build();
|
||||
app.Configure();
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>false</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
|
@ -10,7 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Release\net5.0\publish\</PublishUrl>
|
||||
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
"ConnectionStrings": {
|
||||
"DatabaseConnection": "Server=#########;Database=#########;User Id=#########;Password=#########;MultipleActiveResultSets=true"
|
||||
},
|
||||
"Host": {
|
||||
"UseWindowsService": false
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
|
|
Loading…
Reference in New Issue