Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<TypeScriptToolsVersion>3.0</TypeScriptToolsVersion>
<SpaRoot>ClientApp\</SpaRoot>
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
<UserSecretsId>EqDemo.AspNetCoreVue.AdvancedSearch</UserSecretsId>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<SpaProxyLaunchCommand>npm run serve -- --port 8085</SpaProxyLaunchCommand>
<SpaProxyServerUrl>http://localhost:8085</SpaProxyServerUrl>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Korzh.DbUtils.Sqlite" Version="1.4.1" />
<PackageReference Include="Korzh.EasyQuery.SqLiteGate" Version="7.4.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.1" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="6.34.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.11" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="6.35.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.3" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.34.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.35.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="VueCliMiddleware" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.11" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
Expand Down Expand Up @@ -58,11 +59,11 @@
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" />
<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="$(SpaRoot)build\**" />
<DistFiles Include="$(SpaRoot)dist\**" />
<ResolvedFileToPublish Include="@(DistFiles-&gt;'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
</Project>
</Project>
8 changes: 5 additions & 3 deletions AspNetCore/Vue2/AdvancedSearch/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
}
},
"EqVueDemo": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
}
41 changes: 16 additions & 25 deletions AspNetCore/Vue2/AdvancedSearch/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using System.IO;

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.EntityFrameworkCore;

using VueCliMiddleware;

using Korzh.EasyQuery.Services;
using EasyData.Export;

Expand Down Expand Up @@ -44,12 +44,6 @@ public void ConfigureServices(IServiceCollection services)

services.AddControllersWithViews();

// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});

services.AddEasyQuery()
.UseSqlManager()
.AddDefaultExporters()
Expand Down Expand Up @@ -77,11 +71,17 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseCors("AllowAllPolicy");

app.UseHttpsRedirection();
app.UseStaticFiles();
if (!env.IsDevelopment()) {
app.UseSpaStaticFiles();

// Serve Vue SPA build output from ClientApp/dist in production
var spaPath = Path.Combine(env.ContentRootPath, "ClientApp", "dist");
if (Directory.Exists(spaPath)) {
var fileProvider = new PhysicalFileProvider(spaPath);
app.UseDefaultFiles(new DefaultFilesOptions { FileProvider = fileProvider });
app.UseStaticFiles(new StaticFileOptions { FileProvider = fileProvider });
}

app.UseStaticFiles();


app.UseRouting();

Expand All @@ -103,24 +103,15 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller}/{action=Index}/{id?}");
});

app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
spa.Options.StartupTimeout = TimeSpan.FromMinutes(2);

if (env.IsDevelopment())
{
// run npm process with client app
spa.UseVueCli(npmScript: "serve", port: 8085, regex: "Compiled ");
// if you just prefer to proxy requests from client app, use proxy to SPA dev server instead:
// app should be already running before starting a .NET client
// spa.UseProxyToSpaDevelopmentServer("http://localhost:8080"); // your Vue app port
if (Directory.Exists(Path.Combine(env.ContentRootPath, "ClientApp", "dist"))) {
endpoints.MapFallbackToFile("index.html", new StaticFileOptions {
FileProvider = new PhysicalFileProvider(
Path.Combine(env.ContentRootPath, "ClientApp", "dist"))
});
}
});


//Init demo database (if necessary)
app.EnsureDbInitialized(Configuration, env);
}
Expand Down