Skip to content

Migrate to .NET 6 #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions AspNetCoreVueStarter.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
Expand All @@ -19,8 +19,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="5.0.17" />
<PackageReference Include="VueCliMiddleware" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.0" />
<PackageReference Include="VueCliMiddleware" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
61 changes: 54 additions & 7 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,61 @@ public static void Main(string[] args)
return;
}

CreateHostBuilder(args).Build().Run();
}
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
builder.Services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}

if (https) app.UseHttpsRedirection();

app.UseStaticFiles();
if (!app.Environment.IsDevelopment())
{
app.UseSpaStaticFiles();
}

app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller}/{action=Index}/{id?}");
});

app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
if (app.Environment.IsDevelopment())
{
webBuilder.UseStartup<Startup>();
});
if (mode == "start")
{
spa.UseVueCli(npmScript: "serve", port: port, forceKill: true, https: https);
}

if (mode == "attach")
{
spa.UseProxyToSpaDevelopmentServer($"{(https ? "https" : "http")}://localhost:{port}");
}
}
});

app.Run();
}
}
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ASP.NET Core Vue Starter

The repository contains an ASP.&#8203;NET Core + Vue.js starter template. The template runs on ASP.NET Core 5.0 and is created by Vue CLI 4.0 with a new plugin based architecture allowing developers to interactively scaffold a new project with just a one command.
The repository contains an ASP.&#8203;NET Core + Vue.js starter template. The template runs on ASP.NET Core 6.0 and is created by Vue CLI 4.0 with a new plugin based architecture allowing developers to interactively scaffold a new project with just a one command.

Original article how to create the starter template is available [here](https://medium.com/software-ateliers/asp-net-core-vue-template-with-custom-configuration-using-cli-3-0-8288e18ae80b).

Expand Down Expand Up @@ -28,7 +28,7 @@ Original article how to create the starter template is available [here](https://

## Used Technology Stack

**ASP.NET Core 5.0:**
**ASP.NET Core 6.0:**

* Web.API
* Vue CLI and JavaScript Services middlewares to integrate with client app
Expand All @@ -46,7 +46,7 @@ Original article how to create the starter template is available [here](https://

## Prerequisites

* [.NET Core](https://www.microsoft.com/net/download/windows) >= 5.0
* [.NET Core](https://www.microsoft.com/net/download/windows) >= 6.0
* [NodeJS](https://nodejs.org/) >= 8.9
* [Vue CLI](https://cli.vuejs.org/) >= 4.0
* Your favourite editor (I prefer [VS Code](https://code.visualstudio.com/)), or VS 2017/19
Expand Down Expand Up @@ -159,4 +159,4 @@ Copyright &copy; 2018 - 2022 [Software Ateliers](https://github.com/SoftwareAtel

## Where to find me

Medium: [Software Ateliers](https://medium.com/software-ateliers) | Twitter: [@SAteliers](https://twitter.com/SAteliers)
Medium: [Software Ateliers](https://medium.com/software-ateliers) | Twitter: [@SAteliers](https://twitter.com/SAteliers)