Skip to content

Commit

Permalink
🐛 Fixes #1282 exclude razor pages from api only template
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontaylordev committed Dec 2, 2024
1 parent 36373b2 commit c865545
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"generator": "constant",
"replaces": "caPackageVersion",
"parameters": {
"value": "9.0.5"
"value": "9.0.6"
}
},
"caRepositoryUrl": {
Expand Down Expand Up @@ -194,6 +194,7 @@
"exclude": [
"src/Web/ClientApp/**",
"src/Web/ClientApp-React/**",
"src/Web/Pages/**",
"src/Web/Templates/**",
"src/Web/config.nswag",
"src/Web/config-react.nswag",
Expand Down
4 changes: 2 additions & 2 deletions CleanArchitecture.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<metadata>

<id>Clean.Architecture.Solution.Template</id>
<version>9.0.5</version>
<version>9.0.6</version>
<title>Clean Architecture Solution Template</title>
<authors>JasonTaylorDev</authors>
<description>Clean Architecture Solution Template for .NET 9.</description>
<summary>
A Clean Architecture Solution Template for creating apps using Angular, React, or Web API only with ASP.NET Core.
</summary>
<releaseNotes>
✨ Add support for PostgreSQL
🐛 Exclude src/Web/Pages in API template.
</releaseNotes>

<projectUrl>https://github.com/JasonTaylorDev/CleanArchitecture</projectUrl>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The following prerequisites are required to build and run the solution:

The easiest way to get started is to install the [.NET template](https://www.nuget.org/packages/Clean.Architecture.Solution.Template):
```
dotnet new install Clean.Architecture.Solution.Template::9.0.5
dotnet new install Clean.Architecture.Solution.Template::9.0.6
```

Once installed, create a new solution using the template. You can choose to use Angular, React, or create a Web API-only solution. Specify the client framework using the `-cf` or `--client-framework` option, and provide the output directory where your project will be created. Here are some examples:
Expand Down
2 changes: 2 additions & 0 deletions src/Web/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public static void AddWebServices(this IHostApplicationBuilder builder)

builder.Services.AddExceptionHandler<CustomExceptionHandler>();

#if (!UseApiOnly)
builder.Services.AddRazorPages();
#endif

// Customise default API behaviour
builder.Services.Configure<ApiBehaviorOptions>(options =>
Expand Down
14 changes: 8 additions & 6 deletions src/Web/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using CleanArchitecture.Infrastructure.Data;

var builder = WebApplication.CreateBuilder(args);


// Add services to the container.
#if (UseAspire)
builder.AddServiceDefaults();
Expand All @@ -24,8 +24,8 @@
app.UseHsts();
}

#if (!UseAspire)
app.UseHealthChecks("/health");
#if (!UseAspire)
app.UseHealthChecks("/health");
#endif
app.UseHttpsRedirection();
app.UseStaticFiles();
Expand All @@ -36,13 +36,15 @@
settings.DocumentPath = "/api/specification.json";
});

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

#if (!UseApiOnly)
app.MapRazorPages();

app.MapFallbackToFile("index.html");
#endif

app.UseExceptionHandler(options => { });

Expand Down

0 comments on commit c865545

Please sign in to comment.