aboutsummaryrefslogtreecommitdiff
path: root/src/ext/NetFx/be
diff options
context:
space:
mode:
Diffstat (limited to 'src/ext/NetFx/be')
-rw-r--r--src/ext/NetFx/be/NetfxBundleExtension.cpp102
-rw-r--r--src/ext/NetFx/be/NetfxBundleExtension.h17
-rw-r--r--src/ext/NetFx/be/detectnetcore.cpp140
-rw-r--r--src/ext/NetFx/be/detectnetcore.h9
-rw-r--r--src/ext/NetFx/be/netfxbe.cpp62
-rw-r--r--src/ext/NetFx/be/netfxbe.def8
-rw-r--r--src/ext/NetFx/be/netfxbe.vcxproj77
-rw-r--r--src/ext/NetFx/be/netfxsearch.cpp149
-rw-r--r--src/ext/NetFx/be/netfxsearch.h76
-rw-r--r--src/ext/NetFx/be/precomp.cpp3
-rw-r--r--src/ext/NetFx/be/precomp.h33
11 files changed, 676 insertions, 0 deletions
diff --git a/src/ext/NetFx/be/NetfxBundleExtension.cpp b/src/ext/NetFx/be/NetfxBundleExtension.cpp
new file mode 100644
index 00000000..838a97c1
--- /dev/null
+++ b/src/ext/NetFx/be/NetfxBundleExtension.cpp
@@ -0,0 +1,102 @@
1// 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.
2
3#include "precomp.h"
4#include "BextBaseBundleExtension.h"
5
6class CWixNetfxBundleExtension : public CBextBaseBundleExtension
7{
8public: // IBundleExtension
9 virtual STDMETHODIMP Search(
10 __in LPCWSTR wzId,
11 __in LPCWSTR wzVariable
12 )
13 {
14 HRESULT hr = S_OK;
15
16 hr = NetfxSearchExecute(&m_searches, wzId, wzVariable, m_pEngine, m_sczBaseDirectory);
17
18 return hr;
19 }
20
21public: //CBextBaseBundleExtension
22 virtual STDMETHODIMP Initialize(
23 __in const BUNDLE_EXTENSION_CREATE_ARGS* pCreateArgs
24 )
25 {
26 HRESULT hr = S_OK;
27 LPWSTR sczModulePath = NULL;
28 IXMLDOMDocument* pixdManifest = NULL;
29 IXMLDOMNode* pixnBundleExtension = NULL;
30
31 hr = __super::Initialize(pCreateArgs);
32 BextExitOnFailure(hr, "CBextBaseBundleExtension initialization failed.");
33
34 hr = PathForCurrentProcess(&sczModulePath, m_hInstance);
35 BextExitOnFailure(hr, "Failed to get bundle extension path.");
36
37 hr = PathGetDirectory(sczModulePath, &m_sczBaseDirectory);
38 BextExitOnFailure(hr, "Failed to get bundle extension base directory.");
39
40 hr = XmlLoadDocumentFromFile(m_sczBundleExtensionDataPath, &pixdManifest);
41 BextExitOnFailure(hr, "Failed to load bundle extension manifest from path: %ls", m_sczBundleExtensionDataPath);
42
43 hr = BextGetBundleExtensionDataNode(pixdManifest, NETFX_BUNDLE_EXTENSION_ID, &pixnBundleExtension);
44 BextExitOnFailure(hr, "Failed to get BundleExtension '%ls'", NETFX_BUNDLE_EXTENSION_ID);
45
46 hr = NetfxSearchParseFromXml(&m_searches, pixnBundleExtension);
47 BextExitOnFailure(hr, "Failed to parse searches from bundle extension manifest.");
48
49 LExit:
50 ReleaseObject(pixnBundleExtension);
51 ReleaseObject(pixdManifest);
52 ReleaseStr(sczModulePath);
53
54 return hr;
55 }
56
57public:
58 CWixNetfxBundleExtension(
59 __in HINSTANCE hInstance,
60 __in IBundleExtensionEngine* pEngine
61 ) : CBextBaseBundleExtension(pEngine)
62 {
63 m_searches = { };
64 m_hInstance = hInstance;
65 m_sczBaseDirectory = NULL;
66 }
67
68 ~CWixNetfxBundleExtension()
69 {
70 NetfxSearchUninitialize(&m_searches);
71 ReleaseStr(m_sczBaseDirectory);
72 }
73
74private:
75 NETFX_SEARCHES m_searches;
76 HINSTANCE m_hInstance;
77 LPWSTR m_sczBaseDirectory;
78};
79
80HRESULT NetfxBundleExtensionCreate(
81 __in HINSTANCE hInstance,
82 __in IBundleExtensionEngine* pEngine,
83 __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs,
84 __out IBundleExtension** ppBundleExtension
85 )
86{
87 HRESULT hr = S_OK;
88 CWixNetfxBundleExtension* pExtension = NULL;
89
90 pExtension = new CWixNetfxBundleExtension(hInstance, pEngine);
91 BextExitOnNull(pExtension, hr, E_OUTOFMEMORY, "Failed to create new CWixNetfxBundleExtension.");
92
93 hr = pExtension->Initialize(pArgs);
94 BextExitOnFailure(hr, "CWixNetfxBundleExtension initialization failed.");
95
96 *ppBundleExtension = pExtension;
97 pExtension = NULL;
98
99LExit:
100 ReleaseObject(pExtension);
101 return hr;
102}
diff --git a/src/ext/NetFx/be/NetfxBundleExtension.h b/src/ext/NetFx/be/NetfxBundleExtension.h
new file mode 100644
index 00000000..0746dbed
--- /dev/null
+++ b/src/ext/NetFx/be/NetfxBundleExtension.h
@@ -0,0 +1,17 @@
1#pragma once
2// 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.
3
4
5// constants
6
7#define NETFX_BUNDLE_EXTENSION_ID BUNDLE_EXTENSION_DECORATION(L"NetfxBundleExtension")
8
9
10// function declarations
11
12HRESULT NetfxBundleExtensionCreate(
13 __in HINSTANCE hInstance,
14 __in IBundleExtensionEngine* pEngine,
15 __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs,
16 __out IBundleExtension** ppBundleExtension
17 );
diff --git a/src/ext/NetFx/be/detectnetcore.cpp b/src/ext/NetFx/be/detectnetcore.cpp
new file mode 100644
index 00000000..42156692
--- /dev/null
+++ b/src/ext/NetFx/be/detectnetcore.cpp
@@ -0,0 +1,140 @@
1// 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.
2
3#include "precomp.h"
4
5HRESULT DetectNetCore(
6 __in NETFX_NET_CORE_PLATFORM platform,
7 __in NETFX_NET_CORE_RUNTIME_TYPE runtimeType,
8 __in LPCWSTR wzMajorVersion,
9 __in LPCWSTR wzBaseDirectory,
10 __inout LPWSTR* psczLatestVersion
11 )
12{
13 HRESULT hr = S_OK;
14 LPCWSTR wzRuntimeType = NULL;
15 LPCWSTR wzPlatformName = NULL;
16 LPWSTR sczExePath = NULL;
17 LPWSTR sczCommandLine = NULL;
18 HANDLE hProcess = NULL;
19 HANDLE hStdOutErr = INVALID_HANDLE_VALUE;
20 BYTE* rgbOutput = NULL;
21 DWORD cbOutput = 0;
22 DWORD cbTotalRead = 0;
23 DWORD cbRead = 0;
24 DWORD dwExitCode = 0;
25
26 ReleaseNullStr(*psczLatestVersion);
27
28 switch (runtimeType)
29 {
30 case NETFX_NET_CORE_RUNTIME_TYPE_ASPNET:
31 wzRuntimeType = L"Microsoft.AspNetCore.App";
32 break;
33 case NETFX_NET_CORE_RUNTIME_TYPE_CORE:
34 wzRuntimeType = L"Microsoft.NETCore.App";
35 break;
36 case NETFX_NET_CORE_RUNTIME_TYPE_DESKTOP:
37 wzRuntimeType = L"Microsoft.WindowsDesktop.App";
38 break;
39 default:
40 BextExitWithRootFailure(hr, E_INVALIDARG, "Unknown runtime type: %u", runtimeType);
41 break;
42 }
43
44 switch (platform)
45 {
46 case NETFX_NET_CORE_PLATFORM_ARM64:
47 wzPlatformName = L"arm64";
48 break;
49 case NETFX_NET_CORE_PLATFORM_X64:
50 wzPlatformName = L"x64";
51 break;
52 case NETFX_NET_CORE_PLATFORM_X86:
53 wzPlatformName = L"x86";
54 break;
55 default:
56 BextExitWithRootFailure(hr, E_INVALIDARG, "Unknown platform: %u", platform);
57 break;
58 }
59
60 hr = StrAllocFormatted(&sczExePath, L"%ls%ls\\netcoresearch.exe", wzBaseDirectory, wzPlatformName);
61 BextExitOnFailure(hr, "Failed to build netcoresearch.exe path.");
62
63 hr = StrAllocFormatted(&sczCommandLine, L"\"%ls\" %ls %ls", sczExePath, wzMajorVersion, wzRuntimeType);
64 BextExitOnFailure(hr, "Failed to build netcoresearch.exe command line.");
65
66 hr = ProcExecute(sczExePath, sczCommandLine, &hProcess, NULL, &hStdOutErr);
67 if (HRESULT_FROM_WIN32(ERROR_EXE_MACHINE_TYPE_MISMATCH) == hr)
68 {
69 ExitFunction1(hr = S_FALSE);
70 }
71 BextExitOnFailure(hr, "Failed to run: %ls", sczCommandLine);
72
73 cbOutput = 64;
74
75 rgbOutput = reinterpret_cast<BYTE*>(MemAlloc(cbOutput, TRUE));
76 BextExitOnNull(rgbOutput, hr, E_OUTOFMEMORY, "Failed to alloc output string.");
77
78 while (::ReadFile(hStdOutErr, rgbOutput + cbTotalRead, cbOutput - cbTotalRead, &cbRead, NULL))
79 {
80 cbTotalRead += cbRead;
81
82 if (cbTotalRead == cbOutput)
83 {
84 cbOutput *= 2;
85
86 LPVOID pvNew = MemReAlloc(rgbOutput, cbOutput, TRUE);
87 BextExitOnNull(pvNew, hr, E_OUTOFMEMORY, "Failed to realloc output string.");
88
89 rgbOutput = reinterpret_cast<BYTE*>(pvNew);
90 }
91 }
92
93 if (ERROR_BROKEN_PIPE != ::GetLastError())
94 {
95 BextExitWithLastError(hr, "Failed to read netcoresearch.exe output.");
96 }
97
98 hr = ProcWaitForCompletion(hProcess, INFINITE, &dwExitCode);
99 BextExitOnFailure(hr, "Failed to wait for netcoresearch.exe to exit.");
100
101 if (0 != dwExitCode)
102 {
103 BextExitWithRootFailure(hr, E_UNEXPECTED, "netcoresearch.exe failed with exit code: 0x%x\r\nOutput:\r\n%hs", dwExitCode, rgbOutput);
104 }
105
106 if (*rgbOutput)
107 {
108 hr = StrAllocStringAnsi(psczLatestVersion, reinterpret_cast<LPSTR>(rgbOutput), 0, CP_UTF8);
109 BextExitOnFailure(hr, "Failed to widen output string: %hs", rgbOutput);
110 }
111
112LExit:
113 ReleaseFileHandle(hStdOutErr);
114 ReleaseHandle(hProcess);
115 ReleaseMem(rgbOutput);
116 ReleaseStr(sczCommandLine);
117 ReleaseStr(sczExePath);
118
119 return hr;
120}
121
122HRESULT NetfxPerformDetectNetCore(
123 __in LPCWSTR wzVariable,
124 __in NETFX_SEARCH* pSearch,
125 __in IBundleExtensionEngine* pEngine,
126 __in LPCWSTR wzBaseDirectory
127 )
128{
129 HRESULT hr = S_OK;
130 LPWSTR sczLatestVersion = FALSE;
131
132 hr = DetectNetCore(pSearch->NetCoreSearch.platform, pSearch->NetCoreSearch.runtimeType, pSearch->NetCoreSearch.sczMajorVersion, wzBaseDirectory, &sczLatestVersion);
133 BextExitOnFailure(hr, "DetectNetCore failed.");
134
135 hr = pEngine->SetVariableVersion(wzVariable, sczLatestVersion);
136 BextExitOnFailure(hr, "Failed to set variable '%ls' to '%ls'", wzVariable, sczLatestVersion);
137
138LExit:
139 return hr;
140}
diff --git a/src/ext/NetFx/be/detectnetcore.h b/src/ext/NetFx/be/detectnetcore.h
new file mode 100644
index 00000000..ef93b39b
--- /dev/null
+++ b/src/ext/NetFx/be/detectnetcore.h
@@ -0,0 +1,9 @@
1#pragma once
2// 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.
3
4HRESULT NetfxPerformDetectNetCore(
5 __in LPCWSTR wzVariable,
6 __in NETFX_SEARCH* pSearch,
7 __in IBundleExtensionEngine* pEngine,
8 __in LPCWSTR wzBaseDirectory
9 );
diff --git a/src/ext/NetFx/be/netfxbe.cpp b/src/ext/NetFx/be/netfxbe.cpp
new file mode 100644
index 00000000..3a34cea3
--- /dev/null
+++ b/src/ext/NetFx/be/netfxbe.cpp
@@ -0,0 +1,62 @@
1// 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.
2
3#include "precomp.h"
4#include "BextBaseBundleExtensionProc.h"
5
6static HINSTANCE vhInstance = NULL;
7static IBundleExtension* vpBundleExtension = NULL;
8
9// function definitions
10
11extern "C" BOOL WINAPI DllMain(
12 __in HINSTANCE hInstance,
13 __in DWORD dwReason,
14 __in LPVOID /*pvReserved*/
15 )
16{
17 switch(dwReason)
18 {
19 case DLL_PROCESS_ATTACH:
20 vhInstance = hInstance;
21 break;
22
23 case DLL_PROCESS_DETACH:
24 vhInstance = NULL;
25 break;
26 }
27
28 return TRUE;
29}
30
31extern "C" HRESULT WINAPI BundleExtensionCreate(
32 __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs,
33 __inout BUNDLE_EXTENSION_CREATE_RESULTS* pResults
34 )
35{
36 HRESULT hr = S_OK;
37 IBundleExtensionEngine* pEngine = NULL;
38
39 hr = XmlInitialize();
40 ExitOnFailure(hr, "Failed to initialize XML.");
41
42 hr = BextInitializeFromCreateArgs(pArgs, &pEngine);
43 ExitOnFailure(hr, "Failed to initialize bext");
44
45 hr = NetfxBundleExtensionCreate(vhInstance, pEngine, pArgs, &vpBundleExtension);
46 BextExitOnFailure(hr, "Failed to create WixNetfxBundleExtension");
47
48 pResults->pfnBundleExtensionProc = BextBaseBundleExtensionProc;
49 pResults->pvBundleExtensionProcContext = vpBundleExtension;
50
51LExit:
52 ReleaseObject(pEngine);
53
54 return hr;
55}
56
57extern "C" void WINAPI BundleExtensionDestroy()
58{
59 BextUninitialize();
60 ReleaseNullObject(vpBundleExtension);
61 XmlUninitialize();
62}
diff --git a/src/ext/NetFx/be/netfxbe.def b/src/ext/NetFx/be/netfxbe.def
new file mode 100644
index 00000000..c6605241
--- /dev/null
+++ b/src/ext/NetFx/be/netfxbe.def
@@ -0,0 +1,8 @@
1; 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.
2
3
4LIBRARY "netfxbe"
5
6EXPORTS
7 BundleExtensionCreate
8 BundleExtensionDestroy
diff --git a/src/ext/NetFx/be/netfxbe.vcxproj b/src/ext/NetFx/be/netfxbe.vcxproj
new file mode 100644
index 00000000..00588764
--- /dev/null
+++ b/src/ext/NetFx/be/netfxbe.vcxproj
@@ -0,0 +1,77 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3
4<Project DefaultTargets="Build" Toolsxmlns="http://schemas.microsoft.com/developer/msbuild/2003">
5 <ItemGroup Label="ProjectConfigurations">
6 <ProjectConfiguration Include="Debug|ARM64">
7 <Configuration>Debug</Configuration>
8 <Platform>ARM64</Platform>
9 </ProjectConfiguration>
10 <ProjectConfiguration Include="Release|ARM64">
11 <Configuration>Release</Configuration>
12 <Platform>ARM64</Platform>
13 </ProjectConfiguration>
14 <ProjectConfiguration Include="Debug|X64">
15 <Configuration>Debug</Configuration>
16 <Platform>X64</Platform>
17 </ProjectConfiguration>
18 <ProjectConfiguration Include="Release|X64">
19 <Configuration>Release</Configuration>
20 <Platform>X64</Platform>
21 </ProjectConfiguration>
22 <ProjectConfiguration Include="Debug|Win32">
23 <Configuration>Debug</Configuration>
24 <Platform>Win32</Platform>
25 </ProjectConfiguration>
26 <ProjectConfiguration Include="Release|Win32">
27 <Configuration>Release</Configuration>
28 <Platform>Win32</Platform>
29 </ProjectConfiguration>
30 </ItemGroup>
31
32 <PropertyGroup Label="Globals">
33 <ProjectGuid>{B65719C0-B2CC-45F9-AF33-6F147F741ADB}</ProjectGuid>
34 <ConfigurationType>DynamicLibrary</ConfigurationType>
35 <TargetName>netfxbe</TargetName>
36 <CharacterSet>Unicode</CharacterSet>
37 <ProjectModuleDefinitionFile>netfxbe.def</ProjectModuleDefinitionFile>
38 <Description>WiX Toolset Netfx BundleExtension</Description>
39 </PropertyGroup>
40
41 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
42 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
43
44 <PropertyGroup>
45 <ProjectAdditionalLinkLibraries>msi.lib</ProjectAdditionalLinkLibraries>
46 </PropertyGroup>
47
48 <ItemGroup>
49 <ClCompile Include="detectnetcore.cpp" />
50 <ClCompile Include="netfxbe.cpp" />
51 <ClCompile Include="NetfxBundleExtension.cpp" />
52 <ClCompile Include="netfxsearch.cpp" />
53 <ClCompile Include="precomp.cpp">
54 <PrecompiledHeader>Create</PrecompiledHeader>
55 </ClCompile>
56 </ItemGroup>
57
58 <ItemGroup>
59 <ClInclude Include="detectnetcore.h" />
60 <ClInclude Include="NetfxBundleExtension.h" />
61 <ClInclude Include="netfxsearch.h" />
62 <ClInclude Include="precomp.h" />
63 </ItemGroup>
64
65 <ItemGroup>
66 <None Include="netfxbe.def" />
67 </ItemGroup>
68
69 <ItemGroup>
70 <PackageReference Include="WixToolset.BextUtil" />
71
72 <PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
73 <PackageReference Include="GitInfo" PrivateAssets="All" />
74 </ItemGroup>
75
76 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
77</Project>
diff --git a/src/ext/NetFx/be/netfxsearch.cpp b/src/ext/NetFx/be/netfxsearch.cpp
new file mode 100644
index 00000000..3c12161d
--- /dev/null
+++ b/src/ext/NetFx/be/netfxsearch.cpp
@@ -0,0 +1,149 @@
1// 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.
2
3#include "precomp.h"
4
5
6STDMETHODIMP NetfxSearchParseFromXml(
7 __in NETFX_SEARCHES* pSearches,
8 __in IXMLDOMNode* pixnBundleExtension
9 )
10{
11 HRESULT hr = S_OK;
12 IXMLDOMNodeList* pixnNodes = NULL;
13 IXMLDOMNode* pixnNode = NULL;
14 DWORD cNodes = 0;
15 BSTR bstrNodeName = NULL;
16
17 // Select Netfx search nodes.
18 hr = XmlSelectNodes(pixnBundleExtension, L"NetFxNetCoreSearch", &pixnNodes);
19 BextExitOnFailure(hr, "Failed to select Netfx search nodes.");
20
21 // Get Netfx search node count.
22 hr = pixnNodes->get_length((long*)&cNodes);
23 BextExitOnFailure(hr, "Failed to get Netfx search node count.");
24
25 if (!cNodes)
26 {
27 ExitFunction();
28 }
29
30 // Allocate memory for searches.
31 pSearches->rgSearches = (NETFX_SEARCH*)MemAlloc(sizeof(NETFX_SEARCH) * cNodes, TRUE);
32 BextExitOnNull(pSearches->rgSearches, hr, E_OUTOFMEMORY, "Failed to allocate memory for search structs.");
33
34 pSearches->cSearches = cNodes;
35
36 // Parse search elements.
37 for (DWORD i = 0; i < cNodes; ++i)
38 {
39 NETFX_SEARCH* pSearch = &pSearches->rgSearches[i];
40
41 hr = XmlNextElement(pixnNodes, &pixnNode, &bstrNodeName);
42 BextExitOnFailure(hr, "Failed to get next node.");
43
44 // @Id
45 hr = XmlGetAttributeEx(pixnNode, L"Id", &pSearch->sczId);
46 BextExitOnFailure(hr, "Failed to get @Id.");
47
48 // Read type specific attributes.
49 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"NetFxNetCoreSearch", -1))
50 {
51 pSearch->Type = NETFX_SEARCH_TYPE_NET_CORE_SEARCH;
52
53 // @RuntimeType
54 hr = XmlGetAttributeUInt32(pixnNode, L"RuntimeType", reinterpret_cast<DWORD*>(&pSearch->NetCoreSearch.runtimeType));
55 BextExitOnFailure(hr, "Failed to get @RuntimeType.");
56
57 // @Platform
58 hr = XmlGetAttributeUInt32(pixnNode, L"Platform", reinterpret_cast<DWORD*>(&pSearch->NetCoreSearch.platform));
59 BextExitOnFailure(hr, "Failed to get @Platform.");
60
61 // @MajorVersion
62 hr = XmlGetAttributeEx(pixnNode, L"MajorVersion", &pSearch->NetCoreSearch.sczMajorVersion);
63 BextExitOnFailure(hr, "Failed to get @MajorVersion.");
64 }
65 else
66 {
67 BextExitWithRootFailure(hr, E_UNEXPECTED, "Unexpected element name: %ls", bstrNodeName);
68 }
69
70 // prepare next iteration
71 ReleaseNullObject(pixnNode);
72 ReleaseNullBSTR(bstrNodeName);
73 }
74
75LExit:
76 ReleaseBSTR(bstrNodeName);
77 ReleaseObject(pixnNode);
78 ReleaseObject(pixnNodes);
79
80 return hr;
81}
82
83void NetfxSearchUninitialize(
84 __in NETFX_SEARCHES* pSearches
85 )
86{
87 if (pSearches->rgSearches)
88 {
89 for (DWORD i = 0; i < pSearches->cSearches; ++i)
90 {
91 NETFX_SEARCH* pSearch = &pSearches->rgSearches[i];
92
93 ReleaseStr(pSearch->sczId);
94 }
95 MemFree(pSearches->rgSearches);
96 }
97}
98
99STDMETHODIMP NetfxSearchExecute(
100 __in NETFX_SEARCHES* pSearches,
101 __in LPCWSTR wzSearchId,
102 __in LPCWSTR wzVariable,
103 __in IBundleExtensionEngine* pEngine,
104 __in LPCWSTR wzBaseDirectory
105 )
106{
107 HRESULT hr = S_OK;
108 NETFX_SEARCH* pSearch = NULL;
109
110 hr = NetfxSearchFindById(pSearches, wzSearchId, &pSearch);
111 BextExitOnFailure(hr, "Search id '%ls' is unknown to the util extension.", wzSearchId);
112
113 switch (pSearch->Type)
114 {
115 case NETFX_SEARCH_TYPE_NET_CORE_SEARCH:
116 hr = NetfxPerformDetectNetCore(wzVariable, pSearch, pEngine, wzBaseDirectory);
117 break;
118 default:
119 hr = E_UNEXPECTED;
120 }
121
122LExit:
123 return hr;
124}
125
126STDMETHODIMP NetfxSearchFindById(
127 __in NETFX_SEARCHES* pSearches,
128 __in LPCWSTR wzId,
129 __out NETFX_SEARCH** ppSearch
130 )
131{
132 HRESULT hr = S_OK;
133
134 for (DWORD i = 0; i < pSearches->cSearches; ++i)
135 {
136 NETFX_SEARCH* pSearch = &pSearches->rgSearches[i];
137
138 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, pSearch->sczId, -1, wzId, -1))
139 {
140 *ppSearch = pSearch;
141 ExitFunction1(hr = S_OK);
142 }
143 }
144
145 hr = E_NOTFOUND;
146
147LExit:
148 return hr;
149}
diff --git a/src/ext/NetFx/be/netfxsearch.h b/src/ext/NetFx/be/netfxsearch.h
new file mode 100644
index 00000000..ae250690
--- /dev/null
+++ b/src/ext/NetFx/be/netfxsearch.h
@@ -0,0 +1,76 @@
1#pragma once
2// 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.
3
4
5// constants
6
7enum NETFX_SEARCH_TYPE
8{
9 NETFX_SEARCH_TYPE_NONE,
10 NETFX_SEARCH_TYPE_NET_CORE_SEARCH,
11};
12
13enum NETFX_NET_CORE_RUNTIME_TYPE
14{
15 NETFX_NET_CORE_RUNTIME_TYPE_CORE,
16 NETFX_NET_CORE_RUNTIME_TYPE_ASPNET,
17 NETFX_NET_CORE_RUNTIME_TYPE_DESKTOP,
18};
19
20enum NETFX_NET_CORE_PLATFORM
21{
22 NETFX_NET_CORE_PLATFORM_X86,
23 NETFX_NET_CORE_PLATFORM_X64,
24 NETFX_NET_CORE_PLATFORM_ARM64,
25};
26
27
28// structs
29
30typedef struct _NETFX_SEARCH
31{
32 LPWSTR sczId;
33
34 NETFX_SEARCH_TYPE Type;
35 union
36 {
37 struct
38 {
39 NETFX_NET_CORE_RUNTIME_TYPE runtimeType;
40 NETFX_NET_CORE_PLATFORM platform;
41 LPWSTR sczMajorVersion;
42 } NetCoreSearch;
43 };
44} NETFX_SEARCH;
45
46typedef struct _NETFX_SEARCHES
47{
48 NETFX_SEARCH* rgSearches;
49 DWORD cSearches;
50} NETFX_SEARCHES;
51
52
53// function declarations
54
55STDMETHODIMP NetfxSearchParseFromXml(
56 __in NETFX_SEARCHES* pSearches,
57 __in IXMLDOMNode* pixnBundleExtension
58 );
59
60void NetfxSearchUninitialize(
61 __in NETFX_SEARCHES* pSearches
62 );
63
64STDMETHODIMP NetfxSearchExecute(
65 __in NETFX_SEARCHES* pSearches,
66 __in LPCWSTR wzSearchId,
67 __in LPCWSTR wzVariable,
68 __in IBundleExtensionEngine* pEngine,
69 __in LPCWSTR wzBaseDirectory
70 );
71
72STDMETHODIMP NetfxSearchFindById(
73 __in NETFX_SEARCHES* pSearches,
74 __in LPCWSTR wzId,
75 __out NETFX_SEARCH** ppSearch
76 );
diff --git a/src/ext/NetFx/be/precomp.cpp b/src/ext/NetFx/be/precomp.cpp
new file mode 100644
index 00000000..37664a1c
--- /dev/null
+++ b/src/ext/NetFx/be/precomp.cpp
@@ -0,0 +1,3 @@
1// 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.
2
3#include "precomp.h"
diff --git a/src/ext/NetFx/be/precomp.h b/src/ext/NetFx/be/precomp.h
new file mode 100644
index 00000000..33aea9bc
--- /dev/null
+++ b/src/ext/NetFx/be/precomp.h
@@ -0,0 +1,33 @@
1#pragma once
2// 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.
3
4
5#include <windows.h>
6#include <msiquery.h>
7#include <msidefs.h>
8#include <stierr.h>
9
10#include <strsafe.h>
11
12#include <msxml2.h>
13
14#include <dutil.h>
15#include <fileutil.h>
16#include <memutil.h>
17#include <strutil.h>
18#include <pathutil.h>
19#include <procutil.h>
20#include <xmlutil.h>
21
22#include <BundleExtensionEngine.h>
23#include <BundleExtension.h>
24
25#include <IBundleExtensionEngine.h>
26#include <IBundleExtension.h>
27#include <bextutil.h>
28#include <BextBundleExtensionEngine.h>
29
30#include "..\..\beDecor.h"
31#include "netfxsearch.h"
32#include "detectnetcore.h"
33#include "NetfxBundleExtension.h"