Skip to content
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
4 changes: 4 additions & 0 deletions Aspire.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@
<Project Path="playground/Redis/Redis.ApiService/Redis.ApiService.csproj" />
<Project Path="playground/Redis/Redis.AppHost/Redis.AppHost.csproj" />
</Folder>
<Folder Name="/playground/ResourceSubstitution/">
<Project Path="playground/ResourceSubstitution/ResourceSubstitution.Api/ResourceSubstitution.Api.csproj" />
<Project Path="playground/ResourceSubstitution/ResourceSubstitution.AppHost/ResourceSubstitution.AppHost.csproj" />
</Folder>
<Folder Name="/playground/seq/">
<Project Path="playground/seq/Seq.ApiService/Seq.ApiService.csproj" />
<Project Path="playground/seq/Seq.AppHost/Seq.AppHost.csproj" />
Expand Down
11 changes: 11 additions & 0 deletions playground/ResourceSubstitution/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run AppHost",
"type": "aspire",
"request": "launch",
"program": "${workspaceFolder}"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Runtime.InteropServices;

var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();

var app = builder.Build();

app.MapGet("/", () => $"""
👋🌍
🏷️ Host: {Environment.MachineName}
💻 OS: { RuntimeInformation.OSDescription }
🪪 PID: {Environment.ProcessId}
""");

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "",
"applicationUrl": "https://localhost:5450;http://localhost:5451",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "",
"applicationUrl": "http://localhost:5451",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Playground.ServiceDefaults\Playground.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#pragma warning disable ASPIRECSHARPAPPS001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

var builder = DistributedApplication.CreateBuilder(args);

var projectPath = new Projects.ResourceSubstitution_Api().ProjectPath;

// Normal project resource
// Overriding ports from launch settings to avoid conflicting with the substituted resource
builder.AddCSharpApp("project", projectPath)
.WithEndpoint("http", x => x.Port = null)
.WithEndpoint("https", x => x.Port = null)
.WithHttpHealthCheck();

//A regular container resource
builder.AddContainer("container", "aspire/resourcesubstitution.apphost/container-from-project")
.WithImageTag("aspire-image-build")
.WithHttpEndpoint(targetPort: 8080, env: "ASPNETCORE_HTTP_PORTS")
.WithHttpsEndpoint(targetPort: 8443, env: "ASPNETCORE_HTTPS_PORTS")
.WithHttpHealthCheck()
.WithHttpsCertificateConfiguration(ctx =>
{
ctx.EnvironmentVariables["Kestrel__Certificates__Default__Path"] = ctx.CertificatePath;
ctx.EnvironmentVariables["Kestrel__Certificates__Default__KeyPath"] = ctx.KeyPath;
if (ctx.Password is not null)
{
ctx.EnvironmentVariables["Kestrel__Certificates__Default__Password"] = ctx.Password;
}

return Task.CompletedTask;
});

// A container resource, we change to running a project
// Including picking up ports from launch settings
builder.AddContainer("project-from-container", "doesnt-matter")
.RunAsProject(projectPath)
.WithHttpHealthCheck();

// A project resource that we run as a container
// Overriding ports as the launch settings port so as to not conflict with `project-from-container`
builder.AddProject<Projects.ResourceSubstitution_Api>("container-from-project")
.WithEndpoint("http", x => x.Port = null)
.WithEndpoint("https", x => x.Port = null)
.WithHttpHealthCheck()
.RunAsContainer();

// A project resource that we run as a .NET tool
builder.AddProject<Projects.ResourceSubstitution_Api>("tool-from-project")
.RunAsTool();

builder.Build().Run();
Loading
Loading