Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion src/Aspire.Hosting.Azure/AzureEnvironmentResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private Task PublishAsync(PipelineStepContext context)
var azureProvisioningOptions = context.Services.GetRequiredService<IOptions<AzureProvisioningOptions>>();
var activityReporter = context.PipelineContext.Services.GetRequiredService<IPipelineActivityReporter>();
var publishingContext = new AzurePublishingContext(
context.OutputPath ?? throw new InvalidOperationException("OutputPath is required for Azure publishing."),
context.OutputPath,
azureProvisioningOptions.Value,
context.Services,
context.Logger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal sealed class DockerComposePublishingContext(
UnixFileMode.OtherRead | UnixFileMode.OtherWrite;

public readonly IResourceContainerImageBuilder ImageBuilder = imageBuilder;
public readonly string OutputPath = outputPath ?? throw new InvalidOperationException("OutputPath is required for Docker Compose publishing.");
public readonly string OutputPath = outputPath;

internal async Task WriteModelAsync(DistributedApplicationModel model, DockerComposeEnvironmentResource environment)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal sealed class KubernetesPublishingContext(
ILogger logger,
CancellationToken cancellationToken = default)
{
public readonly string OutputPath = outputPath ?? throw new InvalidOperationException("OutputPath is required for Kubernetes publishing.");
public readonly string OutputPath = outputPath;

private readonly Dictionary<string, Dictionary<string, object>> _helmValues = new()
{
Expand Down
23 changes: 22 additions & 1 deletion src/Aspire.Hosting/Pipelines/PipelineContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using System.Diagnostics.CodeAnalysis;
using Aspire.Hosting.ApplicationModel;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace Aspire.Hosting.Pipelines;
Expand Down Expand Up @@ -53,5 +55,24 @@ public sealed class PipelineContext(
/// <summary>
/// Gets the output path for deployment artifacts.
/// </summary>
public string? OutputPath { get; } = outputPath;
public string OutputPath { get; } = outputPath ?? Path.Combine(Environment.CurrentDirectory, "aspire-output");

/// <summary>
/// Gets the intermediate output path for temporary build artifacts.
/// </summary>
public string IntermediateOutputPath { get; } = GetIntermediateOutputPath(serviceProvider);

private static string GetIntermediateOutputPath(IServiceProvider serviceProvider)
Comment thread
eerhardt marked this conversation as resolved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this directory get cleaned up?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont clean anything up. I think it should be relative to your app folder tbh but I just want to flow a property through so we can begin to use it.

{
var configuration = serviceProvider.GetRequiredService<IConfiguration>();
var appHostSha = configuration["AppHost:PathSha256"];

if (!string.IsNullOrEmpty(appHostSha))
{
return Path.Combine(Path.GetTempPath(), "aspire", appHostSha);
}

// Fallback if AppHost:PathSha256 is not available
return Path.Combine(Path.GetTempPath(), "aspire", Guid.NewGuid().ToString("N"));
}
}
7 changes: 6 additions & 1 deletion src/Aspire.Hosting/Pipelines/PipelineStepContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ public sealed class PipelineStepContext
/// <summary>
/// Gets the output path for deployment artifacts.
/// </summary>
public string? OutputPath => PipelineContext.OutputPath;
public string OutputPath => PipelineContext.OutputPath;

/// <summary>
/// Gets the intermediate output path for temporary build artifacts.
/// </summary>
public string IntermediateOutputPath => PipelineContext.IntermediateOutputPath;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Shared/PublishingContextUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public static string GetEnvironmentOutputPath(PipelineStepContext context, IComp
if (context.Model.Resources.OfType<IComputeEnvironmentResource>().Count() > 1)
{
// If there are multiple compute environments, append the environment name to the output path
return Path.Combine(context.OutputPath!, environment.Name);
return Path.Combine(context.OutputPath, environment.Name);
}

// If there is only one compute environment, use the root output path
return context.OutputPath!;
return context.OutputPath;
}
}