Skip to content

Commit

Permalink
upgrade to net6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Nov 24, 2021
1 parent 683cf77 commit be74788
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 99 deletions.
2 changes: 1 addition & 1 deletion MyApp.ServiceInterface/MyApp.ServiceInterface.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 0 additions & 10 deletions MyApp.ServiceInterface/MyServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,8 @@

namespace MyApp.ServiceInterface
{
[Exclude(Feature.Metadata)]
[FallbackRoute("/{PathInfo*}", Matches="AcceptsHtml")]
public class FallbackForClientRoutes
{
public string PathInfo { get; set; }
}

public class MyServices : Service
{
//Return index.html for unmatched requests so routing is handled on client
public object Any(FallbackForClientRoutes request) => Request.GetPageResult("/");

public object Any(Hello request)
{
return new HelloResponse { Result = $"Hello, {request.Name}!" };
Expand Down
2 changes: 1 addition & 1 deletion MyApp.ServiceModel/MyApp.ServiceModel.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions MyApp.Tests/MyApp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<DebugType>portable</DebugType>
<OutputType>Library</OutputType>
</PropertyGroup>
Expand All @@ -10,9 +10,9 @@
<ProjectReference Include="..\MyApp.ServiceInterface\MyApp.ServiceInterface.csproj" />
<ProjectReference Include="..\MyApp.ServiceModel\MyApp.ServiceModel.csproj" />

<PackageReference Include="NUnit" Version="3.12.*" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.*" />
<PackageReference Include="NUnit" Version="3.13.*" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" />
<PackageReference Include="ServiceStack" Version="5.*" />
<PackageReference Include="ServiceStack.Kestrel" Version="5.*" />
</ItemGroup>
Expand Down
36 changes: 36 additions & 0 deletions MyApp/Configure.AppHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Funq;
using ServiceStack;
using MyApp.ServiceInterface;

[assembly: HostingStartup(typeof(MyApp.AppHost))]

namespace MyApp;

public class AppHost : AppHostBase, IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices(services => {
// Configure ASP.NET Core IOC Dependencies
})
.Configure(app => {
// Configure ASP.NET Core App
if (!HasInit)
app.UseServiceStack(new AppHost());
});

public AppHost() : base("MyApp", typeof(MyServices).Assembly) {}

public override void Configure(Container container)
{
RawHttpHandlers.Add(ApiHandlers.Json("/api/{Request}"));

// enable server-side rendering, see: https://sharpscript.net/docs/sharp-pages
Plugins.Add(new SpaFeature {
EnableSpaFallback = true
});

SetConfig(new HostConfig {
AddRedirectParamsToQueryString = true,
});
}
}
6 changes: 4 additions & 2 deletions MyApp/MyApp.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TypeScriptToolsVersion>2.8</TypeScriptToolsVersion>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TypeScriptToolsVersion>latest</TypeScriptToolsVersion>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>

Expand Down
33 changes: 11 additions & 22 deletions MyApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
using System;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using ServiceStack;
var builder = WebApplication.CreateBuilder(args);

namespace MyApp
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
var app = builder.Build();

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(builder =>
{
builder.UseModularStartup<Startup>();
});
}
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// 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.Run();
59 changes: 0 additions & 59 deletions MyApp/Startup.cs

This file was deleted.

0 comments on commit be74788

Please sign in to comment.