Skip to content
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

Better malformed launchsettings error #5145

Merged
merged 6 commits into from
Aug 7, 2024

Conversation

mitchdenny
Copy link
Member

@mitchdenny mitchdenny commented Aug 2, 2024

Fixes #4307

Microsoft Reviewers: Open in CodeFlow

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Aug 2, 2024
@mitchdenny mitchdenny changed the title Mitchdenny/better malformed launchsettings error Better malformed launchsettings error Aug 2, 2024
@mitchdenny mitchdenny self-assigned this Aug 2, 2024
@mitchdenny mitchdenny requested a review from eerhardt August 2, 2024 00:57
@mitchdenny
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mitchdenny
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mitchdenny mitchdenny enabled auto-merge (squash) August 5, 2024 01:55
mitchdenny and others added 2 commits August 5, 2024 12:43
Co-authored-by: James Newton-King <james@newtonking.com>
@mitchdenny mitchdenny requested a review from JamesNK August 5, 2024 06:59
@mitchdenny mitchdenny requested a review from eerhardt August 6, 2024 01:56
@mitchdenny
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mitchdenny mitchdenny requested a review from eerhardt August 7, 2024 04:06
Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +22 to +24
var ex = Assert.Throws<DistributedApplicationException>(() =>
{
var appBuilder = CreateBuilder();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var ex = Assert.Throws<DistributedApplicationException>(() =>
{
var appBuilder = CreateBuilder();
var appBuilder = CreateBuilder();
var ex = Assert.Throws<DistributedApplicationException>(() =>
{

(nit) I like to keep the action inside the Assert.Throws as minimal as possible, so it is obvious what line is throwing the exception.

Comment on lines +43 to +48
var projectDirectoryPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
var projectFilePath = Path.Combine(projectDirectoryPath, "Project.csproj");
var propertiesDirectoryPath = Path.Combine(projectDirectoryPath, "Properties");
var launchSettingsFilePath = Path.Combine(propertiesDirectoryPath, "launchSettings.json");

Directory.CreateDirectory(projectDirectoryPath);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var projectDirectoryPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
var projectFilePath = Path.Combine(projectDirectoryPath, "Project.csproj");
var propertiesDirectoryPath = Path.Combine(projectDirectoryPath, "Properties");
var launchSettingsFilePath = Path.Combine(propertiesDirectoryPath, "launchSettings.json");
Directory.CreateDirectory(projectDirectoryPath);
var projectDirectoryPath = Directory.CreateTempSubdirectory().FullName;
var projectFilePath = Path.Combine(projectDirectoryPath, "Project.csproj");
var propertiesDirectoryPath = Path.Combine(projectDirectoryPath, "Properties");
var launchSettingsFilePath = Path.Combine(propertiesDirectoryPath, "launchSettings.json");

Using CreateTempSubdirectory is easier.

Comment on lines +43 to +48
var projectDirectoryPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
var projectFilePath = Path.Combine(projectDirectoryPath, "Project.csproj");
var propertiesDirectoryPath = Path.Combine(projectDirectoryPath, "Properties");
var launchSettingsFilePath = Path.Combine(propertiesDirectoryPath, "launchSettings.json");

Directory.CreateDirectory(projectDirectoryPath);
Copy link
Member

Choose a reason for hiding this comment

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

Should we be deleting this directory when the test is done so we don't clutter up the temp directory?

@mitchdenny mitchdenny merged commit 5d5ce00 into main Aug 7, 2024
11 checks passed
@mitchdenny mitchdenny deleted the mitchdenny/better-malformed-launchsettings-error branch August 7, 2024 15:26
@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aspire to an existing project error startup
3 participants