Skip to content

Commit

Permalink
Changing to match CLI commands and more optional output location.
Browse files Browse the repository at this point in the history
  • Loading branch information
timheuer committed May 16, 2024
1 parent a01ec55 commit ef1a6d1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
18 changes: 13 additions & 5 deletions src/Commands/ManifestGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,23 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e, Project projec
}
else
{
manifestPath = Path.Combine(solutionPath, options.DefaultPath);
manifestPath = options.RelativeTo == RelativeTo.Solution
? Path.Combine(solutionPath, options.DefaultPath)
: Path.Combine(projectPath, options.DefaultPath);
}

// ensure that the manifestPath directory exists
Directory.CreateDirectory(manifestPath);

// reset the path to include the manifest file name now that the directory exists
manifestPath = Path.Combine(manifestPath, manifestFileName);

await VS.StatusBar.StartAnimationAsync(StatusAnimation.Build);
await VS.StatusBar.ShowProgressAsync(STATUS_MESSAGE, 1, 2);
await pane.WriteLineAsync(OutputWindowManager.GenerateOutputMessage(STATUS_MESSAGE, "ManifestGen", LogLevel.Information));
await pane.WriteLineAsync(OutputWindowManager.GenerateOutputMessage($"Generating using: msbuild /t:GenerateAspireManifest /p:AspireManifestPublishOutputPath={manifestPath}", "ManifestGen", LogLevel.Information));
await pane.WriteLineAsync(OutputWindowManager.GenerateOutputMessage($"Generating using: dotnet run --publisher manifest --output-path {manifestPath}", "ManifestGen", LogLevel.Information));
var result = await Cli.Wrap("dotnet")
.WithArguments($"msbuild /t:GenerateAspireManifest /p:AspireManifestPublishOutputPath={manifestPath}")
.WithArguments($"dotnet run --publisher manifest --output-path {manifestPath}")
.WithWorkingDirectory(projectPath)
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(stdOutBuffer))
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(stdErrBuffer))
Expand All @@ -64,12 +72,12 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e, Project projec
}
else
{
await pane.WriteLineAsync(OutputWindowManager.GenerateOutputMessage($"Manifest created at {manifestPath}\\{manifestFileName}", "ManifestGen", LogLevel.Information));
await pane.WriteLineAsync(OutputWindowManager.GenerateOutputMessage($"Manifest created at {manifestPath}", "ManifestGen", LogLevel.Information));
}

try
{
await VS.Documents.OpenAsync(Path.Combine(manifestPath,manifestFileName));
await VS.Documents.OpenAsync(Path.Combine(manifestPath));
}
catch (Exception ex)
{
Expand Down
18 changes: 16 additions & 2 deletions src/Options/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ public class General : BaseOptionModel<General>
{
[Category("Manifest file")]
[DisplayName("Default path name")]
[Description("The default path of the folder where the manifest file will be generated. This will be at the solution root.")]
[Description("The default path of the folder where the manifest file will be generated.")]
[DefaultValue(".aspire")]
public string DefaultPath { get; set; } = ".aspire";

[Category("Manifest file")]
[DisplayName("Relative to Solution or Project")]
[Description("Choose whether relative to the Solution or Project")]
[DefaultValue(RelativeTo.Project)]
public RelativeTo RelativeTo { get; set; } = RelativeTo.Project;

[Category("Manifest file")]
[DisplayName("Use temporary file")]
[Description("Use a temporary file on disk instead of project location")]
[Description("Use a temporary file on disk instead of project location. Note if this is true, Default path name and Relative path are ignored.")]
[DefaultValue(true)]
public bool UseTempFile { get; set; } = true;

Expand All @@ -28,4 +34,12 @@ public class General : BaseOptionModel<General>
[Description("Enables azd debug output (--debug) to the infra synth")]
[DefaultValue(false)]
public bool AzdDebug { get; set; } = false;
}

public enum RelativeTo
{
[Description("Project")]
Project,
[Description("Solution")]
Solution
}

0 comments on commit ef1a6d1

Please sign in to comment.