Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
35 changes: 0 additions & 35 deletions src/installer/tests/HostActivation.Tests/DotnetArgValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,41 +68,6 @@ public void MissingArgumentValue_Fails()
.And.HaveStdErrContaining($"Failed to parse supported options or their values:");
}

[Fact]
public void File_ExistsNoDirectorySeparator_RoutesToSDK()
{
// Create a file named "build" in the current directory to simulate a file that happens to match the name of a command
string buildFile = Path.Combine(sharedTestState.BaseDirectory.Location, "build");
File.WriteAllText(buildFile, string.Empty);

// Test that "dotnet build" still routes to SDK, not to the file
TestContext.BuiltDotNet.Exec("build")
.WorkingDirectory(sharedTestState.BaseDirectory.Location)
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Fail()
.And.HaveStdErrContaining("The command could not be loaded, possibly because:") // This is a generic error for when we can't tell what exactly the user intended to do
.And.HaveStdErrContaining("Resolving SDKs");
}

[Fact]
public void RelativePathToNonManagedFile_ShowsSpecificError()
{
// Test relative path with directory separator
Directory.CreateDirectory(Path.Combine(sharedTestState.BaseDirectory.Location, "subdir"));
string testFile = Path.Combine(sharedTestState.BaseDirectory.Location, "subdir", "test.json");
File.WriteAllText(testFile, "{}");

string relativePath = Path.GetRelativePath(sharedTestState.BaseDirectory.Location, testFile);
TestContext.BuiltDotNet.Exec(relativePath)
.WorkingDirectory(sharedTestState.BaseDirectory.Location)
.CaptureStdOut()
.CaptureStdErr()
.Execute()
.Should().Fail()
.And.HaveStdErrContaining($"The application '{relativePath}' is not a managed .dll.");
}

[Fact]
public void InvalidFileOrCommand_NoSDK_ListsPossibleIssues()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void Muxer_AssemblyWithDifferentFileExtension_Fails()
.CaptureStdErr()
.Execute()
.Should().Fail()
.And.HaveStdErrContaining($"The application '{appOtherExt}' is not a managed .dll.");
.And.HaveStdErrContaining($"The application '{appOtherExt}' does not exist or is not a managed .dll or .exe");
}

[Fact]
Expand Down
11 changes: 0 additions & 11 deletions src/native/corehost/fxr/command_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,6 @@ namespace
trace::verbose(_X("Application '%s' is not a managed executable."), app_candidate.c_str());
if (!exec_mode)
{
// Check if this is a non-managed file with directory separator that exists
// This should show a specific error instead of routing to CLI
bool has_dir_separator = app_candidate.find(DIR_SEPARATOR) != pal::string_t::npos;
if (has_dir_separator)
{
if (pal::file_exists(app_candidate))
{
trace::error(_X("The application '%s' is not a managed .dll."), app_candidate.c_str());
return StatusCode::InvalidArgFailure;
}
}
// Route to CLI.
return StatusCode::AppArgNotRunnable;
}
Expand Down
Loading