Skip to content

Commit

Permalink
Handle hostfxr errors better and pass down DOTNET_ROOT from the MSBui…
Browse files Browse the repository at this point in the history
…ld harness.
  • Loading branch information
jkoritzinsky committed Sep 20, 2024
1 parent a607c79 commit 5836e65
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/native/dnmd/dnmd.proj
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
<ScriptName>bash ./build-native.sh</ScriptName>
<ScriptName Condition="$([MSBuild]::IsOsPlatform(Windows))">./build-native.cmd</ScriptName>
</PropertyGroup>
<Exec Command="$(ScriptName) -$(Configuration.ToLower()) -$(TargetArchitecture) -os $(TargetOS) $(CrossArg) $(Compiler) $(NinjaArg) $(PortableBuildArg)" />
<Exec Command="$(ScriptName) -$(Configuration.ToLower()) -$(TargetArchitecture) -os $(TargetOS) $(CrossArg) $(Compiler) $(NinjaArg) $(PortableBuildArg)"
EnvironmentVariables="DOTNET_ROOT=$(DotNetRoot)" />
</Target>

<Target Name="RunTests" BeforeTargets="VSTest">
<Exec Command="ctest --test-dir $(DnmdBuildArtifactsDir) -T Test"/>
<Exec Command="ctest --test-dir $(DnmdBuildArtifactsDir) -T Test"
EnvironmentVariables="DOTNET_ROOT=$(DotNetRoot)" />
<ItemGroup>
<CTestResults Include="$(DnmdBuildArtifactsDir)\Testing\**\Test.xml">
<TargetFileName>dnmd-$([System.String]::new('%(RecursiveDir)').TrimEnd('\\')).ctestxml</TargetFileName>
Expand Down
10 changes: 9 additions & 1 deletion src/native/dnmd/test/regpal/pal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ bool pal::ReadFile(pal::path path, malloc_span<uint8_t>& b)
#endif
}

constexpr int NetHostBufferTooSmall = 0x80008098;

pal::path pal::GetCoreClrPath()
{
int result = 0;
Expand All @@ -148,7 +150,13 @@ pal::path pal::GetCoreClrPath()
{
hostfxr_path.reset(new char_t[bufferSize]);
result = get_hostfxr_path(hostfxr_path.get(), &bufferSize, nullptr);
} while (result != 0);
} while (result == NetHostBufferTooSmall);

if (result != 0)
{
std::cerr << "Failed to get hostfxr path. Error code: " << std::hex << result << std::dec << std::endl;
return {};
}

pal::path hostFxrPath = hostfxr_path.get();
void* hostfxrModule = LoadModule(hostfxr_path.get());
Expand Down

0 comments on commit 5836e65

Please sign in to comment.