1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
#include "precomp.h"
HRESULT DetectNetCore(
__in NETFX_NET_CORE_PLATFORM platform,
__in NETFX_NET_CORE_RUNTIME_TYPE runtimeType,
__in LPCWSTR wzMajorVersion,
__in LPCWSTR wzBaseDirectory,
__inout LPWSTR* psczLatestVersion
)
{
HRESULT hr = S_OK;
LPCWSTR wzRuntimeType = NULL;
LPWSTR sczArguments = NULL;
switch (runtimeType)
{
case NETFX_NET_CORE_RUNTIME_TYPE_ASPNET:
wzRuntimeType = L"Microsoft.AspNetCore.App";
break;
case NETFX_NET_CORE_RUNTIME_TYPE_CORE:
wzRuntimeType = L"Microsoft.NETCore.App";
break;
case NETFX_NET_CORE_RUNTIME_TYPE_DESKTOP:
wzRuntimeType = L"Microsoft.WindowsDesktop.App";
break;
default:
BextExitWithRootFailure(hr, E_INVALIDARG, "Unknown runtime type: %u", runtimeType);
break;
}
hr = StrAllocFormatted(&sczArguments, L"runtime %ls %ls", wzMajorVersion, wzRuntimeType);
BextExitOnFailure(hr, "Failed to build runtime netcoresearch.exe arguments.");
hr = RunNetCoreSearch(platform, wzBaseDirectory, sczArguments, psczLatestVersion);
BextExitOnFailure(hr, "Failed to run netcoresearch.exe for runtime.");
LExit:
ReleaseStr(sczArguments);
return hr;
}
HRESULT NetfxPerformDetectNetCore(
__in LPCWSTR wzVariable,
__in NETFX_SEARCH* pSearch,
__in IBootstrapperExtensionEngine* pEngine,
__in LPCWSTR wzBaseDirectory
)
{
HRESULT hr = S_OK;
LPWSTR sczLatestVersion = FALSE;
hr = DetectNetCore(pSearch->NetCoreSearch.platform, pSearch->NetCoreSearch.runtimeType, pSearch->NetCoreSearch.sczMajorVersion, wzBaseDirectory, &sczLatestVersion);
BextExitOnFailure(hr, "DetectNetCore failed.");
hr = pEngine->SetVariableVersion(wzVariable, sczLatestVersion);
BextExitOnFailure(hr, "Failed to set variable '%ls' to '%ls'", wzVariable, sczLatestVersion);
LExit:
ReleaseStr(sczLatestVersion);
return hr;
}
|