Skip to content
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

Adding Aspire host project #14961

Closed
wants to merge 10 commits into from
Closed
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
7 changes: 7 additions & 0 deletions .github/workflows/pr_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ jobs:
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-quality: 'preview'
- name: Update Workload
run: |
dotnet workload update --from-previous-sdk
- name: Setup Aspire
run: |
dotnet workload install aspire
- name: Build
run: |
dotnet build -c Release
Expand Down
30 changes: 30 additions & 0 deletions OrchardCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Sms", "src\Orch
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Sms.Core", "src\OrchardCore\OrchardCore.Sms.Core\OrchardCore.Sms.Core.csproj", "{20356393-B16D-466C-8203-877A534E287D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.AppHost", "src\Aspire\Aspire.AppHost\Aspire.AppHost.csproj", "{B8A5D532-1F7D-40ED-B6B0-BE36C8B81D91}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.ServiceDefaults", "src\Aspire\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj", "{C2BB6BBB-4F5F-4D2F-975D-D50DD38FCABF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Aspire", "Aspire", "{5DC4B8E4-9BE0-4B57-8065-7DC0A44DBD20}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.OrchardCore.Cms.Web", "src\Aspire\Aspire.OrchardCore.Cms.Web\Aspire.OrchardCore.Cms.Web.csproj", "{3DE87BB4-BA03-4C02-861F-6EE51898E682}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.OrchardCore.Mvc.Web", "src\Aspire\Aspire.OrchardCore.Mvc.Web\Aspire.OrchardCore.Mvc.Web.csproj", "{59D2CC21-A422-42D5-8118-C16B7EE52F77}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Search.AzureAI", "src\OrchardCore.Modules\OrchardCore.Search.AzureAI\OrchardCore.Search.AzureAI.csproj", "{5527BACF-FA5D-4617-978B-7EDE8942E6F6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.Search.AzureAI.Core", "src\OrchardCore\OrchardCore.Search.AzureAI.Core\OrchardCore.Search.AzureAI.Core.csproj", "{E9428DE8-5D81-4359-BF84-31435041FF1A}"
Expand Down Expand Up @@ -1339,6 +1348,22 @@ Global
{20356393-B16D-466C-8203-877A534E287D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20356393-B16D-466C-8203-877A534E287D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20356393-B16D-466C-8203-877A534E287D}.Release|Any CPU.Build.0 = Release|Any CPU
{B8A5D532-1F7D-40ED-B6B0-BE36C8B81D91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8A5D532-1F7D-40ED-B6B0-BE36C8B81D91}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8A5D532-1F7D-40ED-B6B0-BE36C8B81D91}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8A5D532-1F7D-40ED-B6B0-BE36C8B81D91}.Release|Any CPU.Build.0 = Release|Any CPU
{C2BB6BBB-4F5F-4D2F-975D-D50DD38FCABF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2BB6BBB-4F5F-4D2F-975D-D50DD38FCABF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2BB6BBB-4F5F-4D2F-975D-D50DD38FCABF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2BB6BBB-4F5F-4D2F-975D-D50DD38FCABF}.Release|Any CPU.Build.0 = Release|Any CPU
{3DE87BB4-BA03-4C02-861F-6EE51898E682}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DE87BB4-BA03-4C02-861F-6EE51898E682}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DE87BB4-BA03-4C02-861F-6EE51898E682}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DE87BB4-BA03-4C02-861F-6EE51898E682}.Release|Any CPU.Build.0 = Release|Any CPU
{59D2CC21-A422-42D5-8118-C16B7EE52F77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59D2CC21-A422-42D5-8118-C16B7EE52F77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59D2CC21-A422-42D5-8118-C16B7EE52F77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59D2CC21-A422-42D5-8118-C16B7EE52F77}.Release|Any CPU.Build.0 = Release|Any CPU
{5527BACF-FA5D-4617-978B-7EDE8942E6F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5527BACF-FA5D-4617-978B-7EDE8942E6F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5527BACF-FA5D-4617-978B-7EDE8942E6F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -1578,6 +1603,11 @@ Global
{2D93F509-1FB3-4E22-92F0-588D0EFBA921} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{CBF6DB53-FD0C-47F8-9E60-A1D247ACFD05} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
{20356393-B16D-466C-8203-877A534E287D} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{B8A5D532-1F7D-40ED-B6B0-BE36C8B81D91} = {5DC4B8E4-9BE0-4B57-8065-7DC0A44DBD20}
{C2BB6BBB-4F5F-4D2F-975D-D50DD38FCABF} = {5DC4B8E4-9BE0-4B57-8065-7DC0A44DBD20}
{5DC4B8E4-9BE0-4B57-8065-7DC0A44DBD20} = {275E087F-A4E2-4A7B-A924-ED68E3A52086}
{3DE87BB4-BA03-4C02-861F-6EE51898E682} = {5DC4B8E4-9BE0-4B57-8065-7DC0A44DBD20}
{59D2CC21-A422-42D5-8118-C16B7EE52F77} = {5DC4B8E4-9BE0-4B57-8065-7DC0A44DBD20}
{5527BACF-FA5D-4617-978B-7EDE8942E6F6} = {90030E85-0C4F-456F-B879-443E8A3F220D}
{E9428DE8-5D81-4359-BF84-31435041FF1A} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
EndGlobalSection
Expand Down
21 changes: 21 additions & 0 deletions src/Aspire/Aspire.AppHost/Aspire.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting" Version="8.0.0-preview.1.23557.2" />
<PackageReference Include="Aspire.StackExchange.Redis" Version="8.0.0-preview.2.23619.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Aspire.OrchardCore.Cms.Web\Aspire.OrchardCore.Cms.Web.csproj" />
<ProjectReference Include="..\Aspire.OrchardCore.Mvc.Web\Aspire.OrchardCore.Mvc.Web.csproj" />
<ProjectReference Include="..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions src/Aspire/Aspire.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var builder = DistributedApplication.CreateBuilder(args);

var redis = builder.AddRedisContainer("Redis", 50963);

builder.AddProject<Projects.Aspire_OrchardCore_Cms_Web>("OrchardCore CMS App")
.WithReference(redis);

builder.AddProject<Projects.Aspire_OrchardCore_Mvc_Web>("OrchardCore MVC App");

await builder.Build().RunAsync();
16 changes: 16 additions & 0 deletions src/Aspire/Aspire.AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15139",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16125"
}
}
}
}
8 changes: 8 additions & 0 deletions src/Aspire/Aspire.AppHost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions src/Aspire/Aspire.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<ItemGroup>
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Application.Cms.Targets\OrchardCore.Application.Cms.Targets.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Logging.NLog\OrchardCore.Logging.NLog.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Shells.Azure\OrchardCore.Shells.Azure.csproj" />
<ProjectReference Include="..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
<Folder Include="Localization\" />
</ItemGroup>

<!-- Necessary as we reference the Project and not the Package -->
<Import Project="..\..\OrchardCore\OrchardCore.Application.Cms.Core.Targets\OrchardCore.Application.Cms.Core.Targets.targets" />
<Import Project="..\..\OrchardCore\OrchardCore.Application.Targets\OrchardCore.Application.Targets.targets" />

<Import Project="..\..\OrchardCore.Build\OrchardCore.Commons.targets" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file is used to ensure the Localization folder is created during deployment
32 changes: 32 additions & 0 deletions src/Aspire/Aspire.OrchardCore.Cms.Web/NLog.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Warn"
internalLogFile="App_Data/logs/internal-nlog.txt">

<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="OrchardCore.Logging.NLog"/>
</extensions>

<targets>
<!-- file target -->
<target xsi:type="File" name="file"
fileName="${var:configDir}/App_Data/logs/orchard-log-${shortdate}.log"
layout="${longdate}|${orchard-tenant-name}|${aspnet-traceidentifier}|${event-properties:item=EventId}|${logger}|${uppercase:${level}}|${message} ${exception:format=ToString,StackTrace}"
/>

<!-- console target -->
<target xsi:type="Console" name="console" />

</targets>

<rules>
<!-- all warnings and above go to the file target -->
<logger name="*" minlevel="Trace" writeTo="file" />

<!-- the hosting lifetime events go to the console and file targets -->
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="file, console" />
</rules>
</nlog>
41 changes: 41 additions & 0 deletions src/Aspire/Aspire.OrchardCore.Cms.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using OrchardCore.Logging;

var builder = WebApplication.CreateBuilder(args);

builder.Host.UseNLogHost();
builder.AddServiceDefaults();

var ocBuilder = builder.Services
.AddOrchardCms()
.AddSetupFeatures("OrchardCore.AutoSetup");

if (builder.Configuration.GetValue<bool>("EnableAzureCoreFeatures"))
{
// Enable Azure based resources to store the shell configs and the data protections.
ocBuilder.AddAzureShellsConfiguration()
.AddGlobalFeatures("OrchardCore.DataProtection.Azure");
}

if (builder.Configuration.GetValue<bool>("EnableRedisCache"))
{
ocBuilder.AddSetupFeatures("OrchardCore.Redis", "OrchardCore.Redis.Lock")
.AddGlobalFeatures("OrchardCore.Redis", "OrchardCore.Redis.Cache", "OrchardCore.Redis.DataProtection", "OrchardCore.Redis.Lock");
}

if (builder.Configuration.GetValue<bool>("EnableAzureStorage"))
{
ocBuilder.AddTenantFeatures("OrchardCore.Media.Azure.Storage");
}

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
}

app.UseStaticFiles();

app.UseOrchardCore();

await app.RunAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:23843",
"sslPort": 44303
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5084",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7179;http://localhost:5084",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
17 changes: 17 additions & 0 deletions src/Aspire/Aspire.OrchardCore.Cms.Web/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"EnableAzureCoreFeatures": false,
"EnableAzureStorage": false,
"EnableRedisCache": true,
"OrchardCore": {
"OrchardCore_Redis": {
"Configuration": "127.0.0.1:50963,allowAdmin=true",
"InstancePrefix": ""
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\OrchardCore.Modules\OrchardCore.Mvc.HelloWorld\OrchardCore.Mvc.HelloWorld.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Application.Mvc.Targets\OrchardCore.Application.Mvc.Targets.csproj" />
<ProjectReference Include="..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
</ItemGroup>

<!-- Necessary as we reference the Project and not the Package -->
<Import Project="..\..\OrchardCore\OrchardCore.Application.Targets\OrchardCore.Application.Targets.targets" />

<Import Project="..\..\OrchardCore.Build\OrchardCore.Commons.targets" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Aspire.OrchardCore.Mvc.Web.Models;

public class ErrorViewModel
{
public string? RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
20 changes: 20 additions & 0 deletions src/Aspire/Aspire.OrchardCore.Mvc.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

builder.Services
.AddOrchardCore()
.AddMvc();

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
}

app.UseStaticFiles();

app.UseOrchardCore();

await app.RunAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:41929",
"sslPort": 44395
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5287",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7244;http://localhost:5287",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Loading