Skip to content

Commit

Permalink
upgraded to .NET Core 3.0 Preview 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad Kirby committed Aug 7, 2019
1 parent 748bc47 commit e1ee00f
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 47 deletions.
3 changes: 3 additions & 0 deletions publish.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dotnet publish -c Release -r win10-x64 /p:PublishSingleFile=true --self-contained true .\src\DynHosts.Client\DynHosts.Client.csproj
dotnet publish -c Release -r win10-x86 /p:PublishSingleFile=true --self-contained true .\src\DynHosts.Client\DynHosts.Client.csproj
dotnet publish -c Release -r win10-x64 --no-self-contained .\src\DynHosts.Server\DynHosts.Server.csproj
9 changes: 6 additions & 3 deletions src/DynHosts.Client/DynHosts.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>dhclient</AssemblyName>
<LangVersion>7.3</LangVersion>
<OutputType>Exe</OutputType>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.3.4" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.4.0-beta.81" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<TargetFramework>netcoreapp2.2</TargetFramework>
<PublishDir>bin\Release\netcoreapp2.2\publish\win-x64</PublishDir>
<TargetFramework>netcoreapp3.0</TargetFramework>
<PublishDir>bin\Release\netcoreapp3.0\publish\win-x64</PublishDir>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<_IsPortable>false</_IsPortable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<TargetFramework>netcoreapp2.2</TargetFramework>
<PublishDir>bin\Release\netcoreapp2.2\publish\win-x86</PublishDir>
<TargetFramework>netcoreapp3.0</TargetFramework>
<PublishDir>bin\Release\netcoreapp3.0\publish\win-x86</PublishDir>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<_IsPortable>false</_IsPortable>
Expand Down
13 changes: 6 additions & 7 deletions src/DynHosts.Server/DynHosts.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>dhserv</AssemblyName>
<LangVersion>7.3</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.3.4" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="2.1.1" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.4.0-beta.81" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0-preview7.19362.4" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="3.0.0-preview7.19362.4" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0-preview7-19378-04" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="3.0.0-preview7.19362.9" />
</ItemGroup>

</Project>
29 changes: 14 additions & 15 deletions src/DynHosts.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Diagnostics;
using System.IO;
using System.ServiceProcess;
using McMaster.Extensions.CommandLineUtils;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.WindowsServices;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;

namespace DynHosts.Server
{
Expand Down Expand Up @@ -67,23 +65,24 @@ public static int Main(string[] args)
.AddEnvironmentVariables()
.Build();

IWebHost host = WebHost.CreateDefaultBuilder()
.UseContentRoot(PathToContentRoot)
.UseUrls(urlsOption.Value())
.UseStartup<Startup>()
.UseKestrel()
.Build();

var webHostService = new WebHostService(host);
var hostBuilder = Host.CreateDefaultBuilder();

if (IsService)
{
ServiceBase.Run(webHostService);
hostBuilder.UseWindowsService();
}
else

IHost host = hostBuilder
.ConfigureWebHostDefaults(webBuilder =>
{
host.Run();
}
webBuilder.UseContentRoot(PathToContentRoot);
webBuilder.UseUrls(urlsOption.Value());
webBuilder.UseStartup<Startup>();
webBuilder.UseKestrel();
})
.Build();

host.Run();

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ by editing this MSBuild file. In order to learn more about this please visit htt
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<ProjectGuid>6fa31c77-b8df-42a2-b959-198ce2fa66e3</ProjectGuid>
<SelfContained>false</SelfContained>
<_IsPortable>true</_IsPortable>
<publishUrl>bin\Release\netcoreapp2.2\publish\win-x64</publishUrl>
<publishUrl>bin\Release\netcoreapp3.0\publish\win-x64</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
Expand Down
27 changes: 11 additions & 16 deletions src/DynHosts.Server/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Hosting;

namespace DynHosts.Server
{
Expand All @@ -25,24 +19,25 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddControllers().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseMvc();

app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

0 comments on commit e1ee00f

Please sign in to comment.