Skip to content

Commit 59e6972

Browse files
github-actions[bot]Copilotmitchdennydavidfowl
authored
[release/9.4] Add user-friendly error handling for aspire new when directory contains existing files (#10550)
* Initial plan * Add user-friendly error handling for exit code 73 in aspire new command Co-authored-by: mitchdenny <[email protected]> * Add comprehensive test for ProjectAlreadyExistsException in DotNetCliRunner Co-authored-by: mitchdenny <[email protected]> * Replace exception-based flow control with direct exit code check for project creation conflicts - Remove ProjectAlreadyExistsException from DotNetCliRunner.NewProjectAsync - Add direct exit code 73 check in DotNetTemplateFactory.ApplyTemplateAsync with descriptive comment - Update unit test to verify exit code 73 is returned instead of expecting exception - All 112 CLI tests pass, maintaining full backward compatibility Co-authored-by: mitchdenny <[email protected]> * Update error message to be more accurate about file conflicts Co-authored-by: davidfowl <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: mitchdenny <[email protected]> Co-authored-by: davidfowl <[email protected]>
1 parent cb6b01e commit 59e6972

19 files changed

+195
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Aspire.Cli.Exceptions;
5+
6+
/// <summary>
7+
/// Exception thrown when attempting to create a project in a directory that already contains files from a previous project.
8+
/// </summary>
9+
internal sealed class ProjectAlreadyExistsException : Exception
10+
{
11+
public ProjectAlreadyExistsException()
12+
: base("The output folder already contains files from a previous project.")
13+
{
14+
}
15+
16+
public ProjectAlreadyExistsException(string message)
17+
: base(message)
18+
{
19+
}
20+
21+
public ProjectAlreadyExistsException(string message, Exception innerException)
22+
: base(message, innerException)
23+
{
24+
}
25+
}

src/Aspire.Cli/Resources/TemplatingStrings.Designer.cs

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Aspire.Cli/Resources/TemplatingStrings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,7 @@
217217
<data name="NoTemplateVersionsFound" xml:space="preserve">
218218
<value>No template versions were found. Please check your internet connection or NuGet source configuration.</value>
219219
</data>
220+
<data name="ProjectAlreadyExists" xml:space="preserve">
221+
<value>The new project cannot be created because it would overwrite existing files in the output folder. Please remove or move the conflicting files, or choose a different location.</value>
222+
</data>
220223
</root>

src/Aspire.Cli/Resources/xlf/TemplatingStrings.cs.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Aspire.Cli/Resources/xlf/TemplatingStrings.de.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Aspire.Cli/Resources/xlf/TemplatingStrings.es.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Aspire.Cli/Resources/xlf/TemplatingStrings.fr.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Aspire.Cli/Resources/xlf/TemplatingStrings.it.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Aspire.Cli/Resources/xlf/TemplatingStrings.ja.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Aspire.Cli/Resources/xlf/TemplatingStrings.ko.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)