Skip to content
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
9 changes: 4 additions & 5 deletions src/Aspire.Cli/Commands/PublishCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ protected override string[] GetRunArguments(string? fullyQualifiedOutputPath, st
{
var baseArgs = new List<string> { "--operation", "publish", "--step", "publish" };

var targetPath = fullyQualifiedOutputPath is not null
? fullyQualifiedOutputPath
: Path.Combine(Environment.CurrentDirectory, "aspire-output");

baseArgs.AddRange(["--output-path", targetPath]);
if (fullyQualifiedOutputPath is not null)
{
baseArgs.AddRange(["--output-path", fullyQualifiedOutputPath]);
}

// Add --log-level and --envionment flags if specified
var logLevel = parseResult.GetValue(_logLevelOption);
Expand Down
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
1 change: 0 additions & 1 deletion src/Aspire.Hosting.Docker/Aspire.Hosting.Docker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

<ItemGroup>
<Compile Include="$(SharedDir)ResourceNameComparer.cs" LinkBase="Shared" />
<Compile Include="$(SharedDir)PublishingContextUtils.cs" LinkBase="Shared" />
<Compile Include="$(SharedDir)PortAllocator.cs" LinkBase="Shared" />
<Compile Include="$(SharedDir)Yaml\*.cs" LinkBase="Shared\Yaml" />
</ItemGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/Aspire.Hosting.Docker/DockerComposeEnvironmentResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Aspire.Hosting.Docker.Resources;
using Aspire.Hosting.Pipelines;
using Aspire.Hosting.Publishing;
using Aspire.Hosting.Utils;
using Microsoft.Extensions.DependencyInjection;

namespace Aspire.Hosting.Docker;
Expand Down Expand Up @@ -87,7 +86,11 @@ ReferenceExpression IComputeEnvironmentResource.GetHostAddressExpression(Endpoin

private Task PublishAsync(PipelineStepContext context)
{
var outputPath = PublishingContextUtils.GetEnvironmentOutputPath(context, this);
// Inline logic from PublishingContextUtils.GetEnvironmentOutputPath
Copy link
Member

Choose a reason for hiding this comment

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

Why not continue using the shared Utils method?

Copy link
Member

Choose a reason for hiding this comment

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

yea I didn't rrealize what it did originally.

var outputPath = context.Model.Resources.OfType<IComputeEnvironmentResource>().Count() > 1
? Path.Combine(context.OutputPath, Name)
: context.OutputPath;

var activityReporter = context.PipelineContext.Services.GetRequiredService<IPipelineActivityReporter>();
var imageBuilder = context.Services.GetRequiredService<IResourceContainerImageBuilder>();

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 @@ -15,7 +15,6 @@
</ItemGroup>

<ItemGroup>
<Compile Include="$(SharedDir)PublishingContextUtils.cs" LinkBase="Shared" />
<Compile Include="$(SharedDir)Yaml\*.cs" LinkBase="Shared\Yaml" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Aspire.Hosting.ApplicationModel;
using Aspire.Hosting.Kubernetes.Extensions;
using Aspire.Hosting.Pipelines;
using Aspire.Hosting.Utils;

namespace Aspire.Hosting.Kubernetes;

Expand Down Expand Up @@ -112,7 +111,10 @@ ReferenceExpression IComputeEnvironmentResource.GetHostAddressExpression(Endpoin

private Task PublishAsync(PipelineStepContext context)
{
var outputPath = PublishingContextUtils.GetEnvironmentOutputPath(context, this);
// Inline logic from PublishingContextUtils.GetEnvironmentOutputPath
var outputPath = context.Model.Resources.OfType<IComputeEnvironmentResource>().Count() > 1
? Path.Combine(context.OutputPath, Name)
: context.OutputPath;

var kubernetesContext = new KubernetesPublishingContext(
context.ExecutionContext,
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)
Copy link
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
Member

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 Directory.CreateTempSubdirectory($"aspire-{appHostSha}").FullName;
}

// Fallback if AppHost:PathSha256 is not available
return Directory.CreateTempSubdirectory("aspire").FullName;
}
}
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
25 changes: 0 additions & 25 deletions src/Shared/PublishingContextUtils.cs

This file was deleted.