Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 3 additions & 2 deletions src/Aspire.Cli/Projects/ProjectLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ await Parallel.ForEachAsync(appHostFiles, parallelOptions, async (candidateFile,
throw new ProjectLocatorException(ErrorStrings.ProjectFileDoesntExist);
}

var supportedProjectFileExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".csproj", ".fsproj", ".vbproj" };
// Handle explicit apphost.cs files
if (projectFile.Name.Equals("apphost.cs", StringComparison.OrdinalIgnoreCase))
{
Expand All @@ -345,8 +346,8 @@ await Parallel.ForEachAsync(appHostFiles, parallelOptions, async (candidateFile,
throw new ProjectLocatorException(ErrorStrings.ProjectFileDoesntExist);
}
}
// Handle .csproj files
else if (projectFile.Extension.Equals(".csproj", StringComparison.OrdinalIgnoreCase))
// Handle .cs|fs|vbproj files
else if (supportedProjectFileExtensions.Contains(projectFile.Extension))
{
logger.LogDebug("Using project file {ProjectFile}", projectFile.FullName);
return projectFile;
Expand Down
10 changes: 7 additions & 3 deletions tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,15 @@ public async Task UseOrFindAppHostProjectFileThrowsIfNoProjectWasFound()
Assert.Equal("No project file found.", ex.Message);
}

[Fact]
public async Task UseOrFindAppHostProjectFileReturnsExplicitProjectIfExistsAndProvided()
[Theory]
[InlineData(".csproj")]
[InlineData(".fsproj")]
[InlineData(".vbproj")]
public async Task UseOrFindAppHostProjectFileReturnsExplicitProjectIfExistsAndProvided(string projectFileExtension)
{
var logger = NullLogger<ProjectLocator>.Instance;
using var workspace = TemporaryWorkspace.Create(outputHelper);
var projectFile = new FileInfo(Path.Combine(workspace.WorkspaceRoot.FullName, "AppHost.csproj"));
var projectFile = new FileInfo(Path.Combine(workspace.WorkspaceRoot.FullName, $"AppHost{projectFileExtension}"));
await File.WriteAllTextAsync(projectFile.FullName, "Not a real project file.");

var runner = new TestDotNetCliRunner();
Expand Down Expand Up @@ -1170,3 +1173,4 @@ public async Task FindExecutableProjectsAsync_FindsMultipleExecutableProjects()
Assert.Contains(executableProjects, p => p.FullName == winExeFile.FullName);
}
}