-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add Aspire starter project scaffolding #4
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project> | ||
| <PropertyGroup> | ||
| <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> | ||
| <CentralPackageVersionsFile>$(MSBuildThisFileDirectory)Directory.Packages.props</CentralPackageVersionsFile> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageVersion Include="Aspire.Hosting" Version="9.0.0" /> | ||
| <PackageVersion Include="Aspire.Hosting.AppHost" Version="9.0.0" /> | ||
| <PackageVersion Include="Aspire.Hosting.MongoDB" Version="9.0.0" /> | ||
|
|
||
| <!-- OpenTelemetry --> | ||
| <PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.10.0" /> | ||
| <PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.10.0" /> | ||
|
|
||
| <!-- Microsoft --> | ||
| <PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" /> | ||
| <PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="10.0.0" /> | ||
| <PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="10.0.0" /> | ||
|
|
||
| <!-- MongoDB --> | ||
| <PackageVersion Include="MongoDB.Entities" Version="25.0.0" /> | ||
| <PackageVersion Include="MongoDB.Driver" Version="3.2.0" /> | ||
|
|
||
| <!-- API Documentation --> | ||
| <PackageVersion Include="Scalar.AspNetCore" Version="1.2.51" /> | ||
|
|
||
| <!-- Testing (for later use) --> | ||
| <PackageVersion Include="xunit" Version="2.8.1" /> | ||
| <PackageVersion Include="xunit.runner.visualstudio" Version="2.8.1" /> | ||
| <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" /> | ||
| <PackageVersion Include="FluentAssertions" Version="6.12.1" /> | ||
| <PackageVersion Include="NSubstitute" Version="5.2.0" /> | ||
| </ItemGroup> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "$schema": "http://json.schemastore.org/solution-manifest-1.0.json", | ||
| "version": "0.1", | ||
| "name": "IssueManager", | ||
| "description": "Issue management application with modern architecture patterns and async/reactive workflows", | ||
| "projects": [ | ||
| "src/AppHost/AppHost.csproj", | ||
| "src/ServiceDefaults/ServiceDefaults.csproj", | ||
| "src/Api/Api.csproj", | ||
| "src/Web/Web.csproj" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "sdk": { | ||
| "version": "10.0.200-preview.0.26103.119" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <LangVersion>14.0</LangVersion> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <RootNamespace>IssueManager.Api</RootNamespace> | ||
| <InvariantGlobalization>false</InvariantGlobalization> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Aspire.Hosting.AppHost" /> | ||
| <PackageReference Include="Microsoft.AspNetCore.OpenApi" /> | ||
| <PackageReference Include="Scalar.AspNetCore" /> | ||
| <PackageReference Include="MongoDB.Entities" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectCapability Include="CanEvaluateItemsWithTargetFramework" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj" /> | ||
| </ItemGroup> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,36 @@ | ||||||||||||||||||||||||||
| using IssueManager.ServiceDefaults; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| var builder = WebApplication.CreateBuilder(args); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| builder.Services.AddServiceDefaults(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| builder.Services.AddOpenApi(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| var app = builder.Build(); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| app.UseHttpsRedirection(); | ||||||||||||||||||||||||||
|
Comment on lines
+7
to
+11
|
||||||||||||||||||||||||||
| builder.Services.AddOpenApi(); | |
| var app = builder.Build(); | |
| app.UseHttpsRedirection(); | |
| builder.Services.AddOpenApi(); | |
| builder.Services.AddAntiforgery(); | |
| var app = builder.Build(); | |
| app.UseHttpsRedirection(); | |
| app.UseAntiforgery(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <LangVersion>14.0</LangVersion> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <RootNamespace>IssueManager.AppHost</RootNamespace> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Aspire.Hosting" /> | ||
| <PackageReference Include="Aspire.Hosting.AppHost" /> | ||
| <PackageReference Include="Aspire.Hosting.MongoDB" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectCapability Include="CanEvaluateItemsWithTargetFramework" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj" /> | ||
| </ItemGroup> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| var builder = DistributedApplication.CreateBuilder(args); | ||
|
|
||
| var mongodb = builder | ||
| .AddMongoDB("mongodb") | ||
| .AddDatabase("issuemanager"); | ||
|
|
||
| var api = builder | ||
| .AddProject("api", "../Api/Api.csproj") | ||
| .WithReference(mongodb); | ||
|
|
||
| builder | ||
| .AddProject("web", "../Web/Web.csproj") | ||
| .WithReference(api); | ||
|
|
||
| builder.Build().Run(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| namespace IssueManager.ServiceDefaults; | ||
|
|
||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Diagnostics.HealthChecks; | ||
|
|
||
| /// <summary> | ||
| /// Extension methods for service defaults configuration. | ||
| /// </summary> | ||
| public static class Extensions | ||
| { | ||
| /// <summary> | ||
| /// Adds default service configuration for Aspire services. | ||
| /// </summary> | ||
| public static IServiceCollection AddServiceDefaults(this IServiceCollection services) | ||
| { | ||
| services.AddServiceDiscovery(); | ||
| return services; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Adds default health check configuration. | ||
| /// </summary> | ||
| public static IHealthChecksBuilder AddDefaultHealthChecks(this IServiceCollection services) | ||
| { | ||
| return services.AddHealthChecks(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
| <PropertyGroup> | ||||
| <TargetFramework>net10.0</TargetFramework> | ||||
| <LangVersion>14.0</LangVersion> | ||||
| <Nullable>enable</Nullable> | ||||
| <ImplicitUsings>enable</ImplicitUsings> | ||||
| <RootNamespace>IssueManager.ServiceDefaults</RootNamespace> | ||||
| </PropertyGroup> | ||||
|
|
||||
| <ItemGroup> | ||||
| <PackageReference Include="Aspire.Hosting" /> | ||||
|
||||
| <PackageReference Include="Aspire.Hosting" /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| @namespace IssueManager.Web | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <base href="/" /> | ||
| <link rel="stylesheet" href="bootstrap/bootstrap.min.css" /> | ||
| <link rel="stylesheet" href="app.css" /> | ||
| <link rel="stylesheet" href="IssueManager.Web.styles.css" /> | ||
| <link rel="icon" type="image/png" href="favicon.png" /> | ||
| </head> | ||
|
|
||
| <body> | ||
| <Routes /> | ||
| <script src="_framework/blazor.web.js"></script> | ||
| </body> | ||
|
|
||
| </html> | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| @namespace IssueManager.Web.Layout | ||
| @inherits LayoutComponentBase | ||
| @implements IAsyncDisposable | ||
|
|
||
| <div class="page"> | ||
| <div class="sidebar"> | ||
| <NavMenu /> | ||
| </div> | ||
|
|
||
| <main> | ||
| <div class="top-row px-4"> | ||
| <a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a> | ||
| </div> | ||
|
|
||
| <article class="content px-4"> | ||
| @Body | ||
| </article> | ||
| </main> | ||
| </div> | ||
|
|
||
| @code { | ||
| async ValueTask IAsyncDisposable.DisposeAsync() | ||
| { | ||
| await Task.CompletedTask; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| @namespace IssueManager.Web.Layout | ||
|
|
||
| <div class="navbar navbar-dark bg-dark"> | ||
| <div class="container-fluid"> | ||
| <a class="navbar-brand" href="">IssueManager</a> | ||
| <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"> | ||
| <span class="navbar-toggler-icon"></span> | ||
| </button> | ||
| <div class="collapse navbar-collapse" id="navbarNav"> | ||
| <ul class="navbar-nav ms-auto"> | ||
| <li class="nav-item"> | ||
| <a class="nav-link" href="">Home</a> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| @code { | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| @namespace IssueManager.Web.Pages | ||
| @page "/" | ||
|
|
||
| <PageTitle>Home</PageTitle> | ||
|
|
||
| <h1>Welcome to IssueManager</h1> | ||
|
|
||
| <p>This application demonstrates modern .NET architecture patterns with Aspire, Blazor, and MongoDB.</p> | ||
|
|
||
| @code { | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| using IssueManager.ServiceDefaults; | ||
| using IssueManager.Web; | ||
|
|
||
| var builder = WebApplication.CreateBuilder(args); | ||
|
|
||
| builder.Services.AddServiceDefaults(); | ||
|
|
||
| builder.Services.AddRazorComponents() | ||
| .AddInteractiveServerComponents(); | ||
|
|
||
| var app = builder.Build(); | ||
|
|
||
| if (!app.Environment.IsDevelopment()) | ||
| { | ||
| app.UseExceptionHandler("/Error", createScopeForErrors: true); | ||
| app.UseHsts(); | ||
| } | ||
|
|
||
| app.UseHttpsRedirection(); | ||
| app.UseStaticFiles(); | ||
| app.UseAntiforgery(); | ||
|
|
||
| app.MapRazorComponents<App>() | ||
| .AddInteractiveServerRenderMode(); | ||
|
|
||
| app.MapHealthChecks("/health"); | ||
|
|
||
| app.Run(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| @namespace IssueManager.Web | ||
|
|
||
| <Router AppAssembly="typeof(App).Assembly"> | ||
| <Found Context="routeData"> | ||
| <RouteView RouteData="@routeData" DefaultLayout="typeof(IssueManager.Web.Layout.MainLayout)" /> | ||
| </Found> | ||
| <NotFound> | ||
| <PageTitle>Not found</PageTitle> | ||
| <LayoutView Layout="typeof(IssueManager.Web.Layout.MainLayout)"> | ||
| <p role="alert">Sorry, there's nothing at this address.</p> | ||
| </LayoutView> | ||
| </NotFound> | ||
| </Router> | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||||||||||||||||||
| <PropertyGroup> | ||||||||||||||||||
| <TargetFramework>net10.0</TargetFramework> | ||||||||||||||||||
| <LangVersion>14.0</LangVersion> | ||||||||||||||||||
| <Nullable>enable</Nullable> | ||||||||||||||||||
| <ImplicitUsings>enable</ImplicitUsings> | ||||||||||||||||||
| <RootNamespace>IssueManager.Web</RootNamespace> | ||||||||||||||||||
| <InvariantGlobalization>false</InvariantGlobalization> | ||||||||||||||||||
| </PropertyGroup> | ||||||||||||||||||
|
|
||||||||||||||||||
| <ItemGroup> | ||||||||||||||||||
| <PackageReference Include="Aspire.Hosting.AppHost" /> | ||||||||||||||||||
| </ItemGroup> | ||||||||||||||||||
|
|
||||||||||||||||||
| <ItemGroup> | ||||||||||||||||||
| <ProjectCapability Include="CanEvaluateItemsWithTargetFramework" /> | ||||||||||||||||||
| </ItemGroup> | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+12
to
+18
|
||||||||||||||||||
| <PackageReference Include="Aspire.Hosting.AppHost" /> | |
| </ItemGroup> | |
| <ItemGroup> | |
| <ProjectCapability Include="CanEvaluateItemsWithTargetFramework" /> | |
| </ItemGroup> | |
| <ProjectCapability Include="CanEvaluateItemsWithTargetFramework" /> | |
| </ItemGroup> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| @using System.Globalization | ||
| @using Microsoft.AspNetCore.Components | ||
| @using Microsoft.AspNetCore.Components.Routing | ||
| @using Microsoft.AspNetCore.Components.Web | ||
| @using IssueManager.Web | ||
| @using IssueManager.Web.Layout | ||
| @using IssueManager.Web.Pages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Api project should not reference the Aspire.Hosting.AppHost package. This package is intended for orchestrator projects (like AppHost) that manage service topology. API services should not include this dependency. Remove this PackageReference from the Api project.