-
Notifications
You must be signed in to change notification settings - Fork 850
[release/13.2] Fix TS AppHost restore config resolution #15625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/13.2
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,16 +61,14 @@ private async Task<TemplateResult> ApplyTypeScriptStarterTemplateAsync(CallbackT | |
| _logger.LogDebug("Copying embedded TypeScript starter template files to '{OutputPath}'.", outputPath); | ||
| await CopyTemplateTreeToDiskAsync("ts-starter", outputPath, ApplyAllTokens, cancellationToken); | ||
|
|
||
| // Write channel to aspire.config.json before restore so package resolution uses the selected channel. | ||
| // Persist the template SDK version before restore so integration and codegen package | ||
| // resolution stays aligned with the project we just created. | ||
| var config = AspireConfigFile.LoadOrCreate(outputPath, aspireVersion); | ||
| if (!string.IsNullOrEmpty(inputs.Channel)) | ||
| { | ||
| var config = AspireConfigFile.Load(outputPath); | ||
| if (config is not null) | ||
| { | ||
| config.Channel = inputs.Channel; | ||
| config.Save(outputPath); | ||
| } | ||
| config.Channel = inputs.Channel; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Write a log message that channel has been set. Could be the comment above here |
||
| } | ||
| config.Save(outputPath); | ||
|
|
||
| var appHostProject = _projectFactory.TryGetProject(new FileInfo(Path.Combine(outputPath, "apphost.ts"))); | ||
| if (appHostProject is not IGuestAppHostSdkGenerator guestProject) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -192,4 +192,42 @@ public void Constructor_UsesUserAspireDirectoryForWorkingDirectory() | |||
| } | ||||
| } | ||||
|
|
||||
| [Fact] | ||||
| public async Task ResolveChannelNameAsync_UsesProjectLocalAspireConfig_NotGlobalChannel() | ||||
| { | ||||
| using var workspace = TemporaryWorkspace.Create(outputHelper); | ||||
|
|
||||
| var aspireConfigPath = Path.Combine(workspace.WorkspaceRoot.FullName, AspireConfigFile.FileName); | ||||
| await File.WriteAllTextAsync(aspireConfigPath, """ | ||||
| { | ||||
| "channel": "pr-new" | ||||
| } | ||||
| """); | ||||
|
|
||||
| var configurationService = new TestConfigurationService | ||||
| { | ||||
| OnGetConfiguration = key => key == "channel" ? "pr-old" : null | ||||
| }; | ||||
|
|
||||
| var nugetService = new BundleNuGetService(new NullLayoutDiscovery(), Microsoft.Extensions.Logging.Abstractions.NullLogger<BundleNuGetService>.Instance); | ||||
| var server = new PrebuiltAppHostServer( | ||||
| workspace.WorkspaceRoot.FullName, | ||||
| "test.sock", | ||||
| new LayoutConfiguration(), | ||||
| nugetService, | ||||
| new TestDotNetCliRunner(), | ||||
| new TestDotNetSdkInstaller(), | ||||
| new Aspire.Cli.Tests.Mcp.MockPackagingService(), | ||||
| configurationService, | ||||
| Microsoft.Extensions.Logging.Abstractions.NullLogger.Instance); | ||||
|
|
||||
| var method = typeof(PrebuiltAppHostServer).GetMethod("ResolveChannelNameAsync", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); | ||||
| Assert.NotNull(method); | ||||
|
|
||||
| var channelTask = Assert.IsType<Task<string?>>(method.Invoke(server, [CancellationToken.None])); | ||||
| var channel = await channelTask; | ||||
|
Comment on lines
+224
to
+228
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why reflection and not make the method internal? There is also reflection in Constructor_UsesUserAspireDirectoryForWorkingDirectory test |
||||
|
|
||||
| Assert.Equal("pr-new", channel); | ||||
| } | ||||
|
|
||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit
Suggested change
|
||||
| } | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicated in DotNetBasedAppHostServiceProject. Is there a place we could put a helper method to avoid duplication?