PinguApps.Aspire.Hosting.Railway.Jobs
1.1.4
dotnet add package PinguApps.Aspire.Hosting.Railway.Jobs --version 1.1.4
NuGet\Install-Package PinguApps.Aspire.Hosting.Railway.Jobs -Version 1.1.4
<PackageReference Include="PinguApps.Aspire.Hosting.Railway.Jobs" Version="1.1.4" />
<PackageVersion Include="PinguApps.Aspire.Hosting.Railway.Jobs" Version="1.1.4" />
<PackageReference Include="PinguApps.Aspire.Hosting.Railway.Jobs" />
paket add PinguApps.Aspire.Hosting.Railway.Jobs --version 1.1.4
#r "nuget: PinguApps.Aspire.Hosting.Railway.Jobs, 1.1.4"
#:package PinguApps.Aspire.Hosting.Railway.Jobs@1.1.4
#addin nuget:?package=PinguApps.Aspire.Hosting.Railway.Jobs&version=1.1.4
#tool nuget:?package=PinguApps.Aspire.Hosting.Railway.Jobs&version=1.1.4
PinguApps.Aspire.Hosting.Railway.Jobs
Publish existing Aspire projects and containers as finite release jobs or scheduled Railway jobs. Normal local Aspire behavior stays unchanged. Create target/deployment parameters and attach publishers only inside IsPublishMode, so local runs require no control-plane credentials. This package uses the shared PinguApps.Aspire.Hosting.Railway target for authentication, ownership, immutable image or source-build deployment, variables, networking, and provider interaction.
Install
dotnet add package PinguApps.Aspire.Hosting.Railway.Jobs --version 1.1.1
Requires .NET 10 and Aspire 13.6.5. Publish PinguApps.Aspire.Hosting.Railway 1.1.0 before this dependent package. See installation and repository setup.
Finite release jobs
using Aspire.Hosting.Railway;
using Aspire.Hosting.Railway.Jobs;
var migration = builder.AddProject<Projects.Migration>("migration").WithReference(database);
var web = builder.AddProject<Projects.Web>("web");
if (builder.ExecutionContext.IsPublishMode)
{
var target = builder.AddRailwayTarget(
"railway",
builder.AddParameter("railway-project-id"),
builder.AddParameter("railway-environment-id"),
builder.AddParameter("railway-api-token", secret: true),
builder.AddParameter("site-key"));
migration.PublishToRailwayJob(target, options =>
{
options.Image = release.MigrationImage; // image@sha256:...
options.Timeout = TimeSpan.FromMinutes(5);
});
web.PublishToRailway(target, options =>
{
options.Image = release.WebImage;
options.DeploymentDependsOn.Add(migration.Resource);
options.Port = 8080;
options.PublicDomain = true;
});
}
Run aspire deploy. Railway starts the retained image without rebuilding it. A finite job always uses restart policy NEVER and no automatic retries. Its deployment step waits for the exact deployment's instances to exit successfully, rather than treating Railway's SUCCESS (running) status as completed work. Failure or timeout fails the step, so the dependent web deployment cannot start.
Migrations, seeding, and managed-media publishing use this finite-job form. Explicitly configure deployment dependencies for required release order. .WaitFor(...) continues to describe local runtime behavior; it is not a release completion gate. Application code must make repeated executions safe: the publisher reuses the same owned service, but does not provide exactly-once business execution.
Build jobs inside Railway
Keep aspire deploy as the entry point and opt in to Railway-owned builds instead of supplying an image:
migration.PublishToRailwayJob(target, options =>
{
options.Build = new RailwayBuildOptions
{
ContextPath = "..",
DockerfilePath = "src/Migration/Dockerfile",
};
options.Timeout = TimeSpan.FromMinutes(10);
});
The deployment machine needs the Railway CLI. The shared core uploads the context and Railway builds and retains the container. Later restarts and cron runs need no GHCR pull token for this workload. The same Build setting works for PublishToRailwayCronJob and TypeScript build: { contextPath: "..", dockerfilePath: "src/Backup/Dockerfile" }. Finite jobs still require successful exit and block dependent services on failure. Build and Image are mutually exclusive; leaving Build unset preserves the existing image-based functionality. See build configuration.
Scheduled jobs
// Within the same publish-only branch, publish a locally declared backup resource:
backup.PublishToRailwayCronJob(target, "0 2 * * *", options =>
{
options.Image = release.BackupImage;
options.StartCommand = "dotnet Backup.dll";
options.MemoryGB = 0.5;
options.VCpus = 0.5;
});
Railway evaluates schedules in UTC and skips a scheduled run while its preceding run remains active. The executable must exit after its work and implement its own runtime deadline. The options timeout bounds deployment publication, not later cron executions. Do not publish a permanent worker as a cron job.
PostgreSQL backups and enquiry retention/dead-letter cleanup use this scheduled form. Production-only selection, credentials, retention policy, and processing logic belong to the consumer AppHost and executable.
TypeScript AppHost
{
"sdk": { "version": "13.6.5" },
"packages": {
"PinguApps.Aspire.Hosting.Railway": "1.1.0",
"PinguApps.Aspire.Hosting.Railway.Jobs": "1.1.1"
}
}
let migration = await builder.addContainer("migration", "ghcr.io/example/migration");
let backup = await builder.addContainer("backup", "ghcr.io/example/backup");
if (await builder.executionContext().isPublishMode()) {
const projectId = await builder.addParameter("railway-project-id");
const environmentId = await builder.addParameter("railway-environment-id");
const apiToken = await builder.addParameter("railway-api-token", { secret: true });
const siteKey = await builder.addParameter("site-key");
const target = await builder.addRailwayTarget("railway", projectId, environmentId, apiToken, siteKey);
migration = await migration.publishToRailwayJob(target, {
image: migrationImageDigest,
timeoutSeconds: 300,
});
backup = await backup.publishToRailwayCronJob(target, "0 2 * * *", {
image: backupImageDigest,
memoryGB: 0.5,
vCpus: 0.5,
});
}
Use await web.withRailwayDeploymentDependency(migration) for the TypeScript release gate. See the TypeScript guide, configuration, and deployment behavior.
Validation
pwsh ./eng/Test-AspireVersionPins.ps1
dotnet test Aspire.Hosting.Railway.Jobs.slnx -c Release
pwsh ./eng/Validate-TypeScriptAppHostPackage.ps1
The package gate compiles against the exact published core dependency in a fresh isolated cache, packs Jobs, verifies its core assembly reference, then restores the same package into a TypeScript fixture, generates bindings, checks TypeScript, and lists the publish/deploy pipelines without provider credentials. Release publication requires this published-dependency path. For an unpublished core change only, prepare a feed explicitly with eng/Prepare-RailwayDependency.ps1 and pass it using -DependencyFeed <feed>; substitute dependencies cannot be used for release publication. See live integration evidence for real aspire deploy validation and retained Railway resources.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Aspire.Hosting (>= 13.6.5)
- MessagePack (>= 3.1.12)
- PinguApps.Aspire.Hosting.Railway (>= 1.1.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.