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

Add arch info in missing framework error #57150

Merged
merged 2 commits into from
Aug 12, 2021
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
29 changes: 15 additions & 14 deletions src/installer/tests/HostActivation.Tests/PortableAppActivation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public void MissingFrameworkInRuntimeConfig_Fails(bool useAppHost)
[Theory]
[InlineData(true)]
[InlineData(false)]
public void AppHost_CLI_FrameworkDependent_MissingRuntimeFramework_ErrorReportedInDialog(bool missingHostfxr)
public void AppHost_CLI_FrameworkDependent_MissingRuntimeFramework_ErrorReportedInStdErr(bool missingHostfxr)
{
var fixture = sharedTestState.PortableAppFixture_Built
.Copy();
Expand All @@ -458,22 +458,24 @@ public void AppHost_CLI_FrameworkDependent_MissingRuntimeFramework_ErrorReported
using (new TestArtifact(invalidDotNet))
{
Directory.CreateDirectory(invalidDotNet);

string expectedErrorCode;
string expectedUrlQuery;
string expectedUrlParameter = null;
string expectedStdErr;
int expectedErrorCode = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this variable moved down?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was no particular reason for moving the declaration order I can change it back. The variable was declared but nothing in the test was checking that the actual exit code was the one expected.

if (missingHostfxr)
{
expectedErrorCode = Constants.ErrorCode.CoreHostLibMissingFailure.ToString("x");
expectedErrorCode = Constants.ErrorCode.CoreHostLibMissingFailure;
expectedStdErr = $"&apphost_version={sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}";
expectedUrlQuery = "missing_runtime=true&";
expectedUrlParameter = $"&apphost_version={sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}";
}
else
{
invalidDotNet = new DotNetBuilder(invalidDotNet, sharedTestState.RepoDirectories.BuiltDotnet, "missingFramework")
.Build()
.BinPath;
expectedErrorCode = Constants.ErrorCode.FrameworkMissingFailure.ToString("x");

expectedErrorCode = Constants.ErrorCode.FrameworkMissingFailure;
expectedStdErr = $"The framework '{Constants.MicrosoftNETCoreApp}', " +
$"version '{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}' ({fixture.RepoDirProvider.BuildArchitecture}) was not found.";
expectedUrlQuery = $"framework={Constants.MicrosoftNETCoreApp}&framework_version={sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}";
}

Expand All @@ -483,14 +485,13 @@ public void AppHost_CLI_FrameworkDependent_MissingRuntimeFramework_ErrorReported
.MultilevelLookup(false)
.Start();

var result = command.WaitForExit(true)
.Should().Fail();
var result = command.WaitForExit(true);
result.Should().Fail()
.And.HaveStdErrContaining($"- https://aka.ms/dotnet-core-applaunch?{expectedUrlQuery}")
.And.HaveStdErrContaining(expectedStdErr);

result.And.HaveStdErrContaining($"- https://aka.ms/dotnet-core-applaunch?{expectedUrlQuery}");
if (expectedUrlParameter != null)
{
result.And.HaveStdErrContaining(expectedUrlParameter);
}
// Some Unix systems will have 8 bit exit codes.
Assert.True(result.ExitCode == expectedErrorCode || result.ExitCode == (expectedErrorCode & 0xFF));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/native/corehost/apphost/apphost.windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace
{
// We don't have a great way of passing out different kinds of detailed error info across components, so
// just match the expected error string. See fx_resolver.messages.cpp.
dialogMsg = pal::string_t(_X("To run this application, you must install .NET.\n\n"));
dialogMsg = pal::string_t(_X("To run this application, you must install missing frameworks for .NET.\n\n"));
pal::string_t line;
pal::stringstream_t ss(g_buffered_errors);
while (std::getline(ss, line, _X('\n'))){
Expand Down
4 changes: 2 additions & 2 deletions src/native/corehost/fxr/fx_resolver.messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ void fx_resolver_t::display_missing_framework_error(
// Display the error message about missing FX.
if (fx_version.length())
{
trace::error(_X("The framework '%s', version '%s' was not found."), fx_name.c_str(), fx_version.c_str());
trace::error(_X("The framework '%s', version '%s' (%s) was not found."), fx_name.c_str(), fx_version.c_str(), get_arch());
}
else
{
trace::error(_X("The framework '%s' was not found."), fx_name.c_str());
trace::error(_X("The framework '%s' (%s) was not found."), fx_name.c_str(), get_arch());
}

if (framework_infos.size())
Expand Down