Skip to content

Commit 15b0f8c

Browse files
Merge pull request #425 from TransactionProcessing/task/#423_runaswindowsservice
Run as win service
2 parents 4859b9d + 60e532f commit 15b0f8c

6 files changed

Lines changed: 7 additions & 25 deletions

File tree

.github/workflows/createrelease.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ jobs:
1818
- name: Get the version
1919
id: get_version
2020
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
21-
22-
- name: Install NET 7
23-
uses: actions/setup-dotnet@v2
24-
with:
25-
dotnet-version: '7.0.x'
26-
21+
2722
- name: Restore Nuget Packages
2823
run: dotnet restore TransactionProcessor.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json
2924

@@ -57,7 +52,7 @@ jobs:
5752
5853
- name: Publish API
5954
if: ${{ github.event.release.prerelease == false }}
60-
run: dotnet publish "TransactionProcessor\TransactionProcessor.csproj" --configuration Release --output publishOutput
55+
run: dotnet publish "TransactionProcessor\TransactionProcessor.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained
6156

6257
- name: Install Octopus CLI
6358
if: ${{ github.event.release.prerelease == false }}

.github/workflows/nightlybuild.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ jobs:
4444
- name: Set Up Variables
4545
run: echo "action_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
4646

47-
- name: Install NET 7
48-
uses: actions/setup-dotnet@v2
49-
with:
50-
dotnet-version: '7.0.101'
51-
5247
- name: Restore Nuget Packages
5348
run: dotnet restore TransactionProcessor.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json
5449

.github/workflows/pullrequest.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v2.3.4
1818

19-
- name: Install NET 7
20-
uses: actions/setup-dotnet@v2
21-
with:
22-
dotnet-version: '7.0.x'
23-
2419
- name: Restore Nuget Packages
2520
run: dotnet restore TransactionProcessor.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json
2621

.github/workflows/pushtomaster.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ jobs:
1919
with:
2020
fetch-depth: 0
2121

22-
- name: Install NET 7
23-
uses: actions/setup-dotnet@v2
24-
with:
25-
dotnet-version: '7.0.x'
26-
2722
- name: Restore Nuget Packages
2823
run: dotnet restore TransactionProcessor.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json
2924

TransactionProcessor/Program.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ public static void Main(string[] args)
3232

3333
public static IHostBuilder CreateHostBuilder(string[] args)
3434
{
35-
Console.Title = "Transaction Processor";
36-
3735
//At this stage, we only need our hosting file for ip and ports
38-
IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
36+
FileInfo fi = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
37+
38+
IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(fi.Directory.FullName)
3939
.AddJsonFile("hosting.json", optional: true)
4040
.AddJsonFile("hosting.development.json", optional: true)
4141
.AddEnvironmentVariables().Build();
4242

4343
IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args);
44+
hostBuilder.UseWindowsService();
4445
hostBuilder.UseLamar();
4546
hostBuilder.ConfigureWebHostDefaults(webBuilder =>
4647
{

TransactionProcessor/TransactionProcessor.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.4.0" />
4444
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.4.0" />
4545
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.4.0" />
46+
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
4647
</ItemGroup>
4748

4849
<ItemGroup>

0 commit comments

Comments
 (0)