diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-04-19 17:15:05 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-04-19 18:35:15 -0500 |
commit | 57fd164d56466a52854e825afd5fdc2b6b97f12a (patch) | |
tree | 7d4ace6d7a55c2a50302e3b6866456026a2c6222 /src/ext/Bal/dnchost | |
parent | 6435d26c7e2ce54ec38d0cc9eb4d2cb10e9614e0 (diff) | |
download | wix-57fd164d56466a52854e825afd5fdc2b6b97f12a.tar.gz wix-57fd164d56466a52854e825afd5fdc2b6b97f12a.tar.bz2 wix-57fd164d56466a52854e825afd5fdc2b6b97f12a.zip |
Replace Dnc.Host with Dnc.HostGenerator to support linker trimming.
Diffstat (limited to 'src/ext/Bal/dnchost')
-rw-r--r-- | src/ext/Bal/dnchost/dnchost.cpp | 5 | ||||
-rw-r--r-- | src/ext/Bal/dnchost/dnchost.h | 1 | ||||
-rw-r--r-- | src/ext/Bal/dnchost/dnchost.vcxproj | 8 | ||||
-rw-r--r-- | src/ext/Bal/dnchost/dncutil.cpp | 42 | ||||
-rw-r--r-- | src/ext/Bal/dnchost/dncutil.h | 5 | ||||
-rw-r--r-- | src/ext/Bal/dnchost/precomp.h | 1 |
6 files changed, 35 insertions, 27 deletions
diff --git a/src/ext/Bal/dnchost/dnchost.cpp b/src/ext/Bal/dnchost/dnchost.cpp index 8ca326fc..dcc9fa56 100644 --- a/src/ext/Bal/dnchost/dnchost.cpp +++ b/src/ext/Bal/dnchost/dnchost.cpp | |||
@@ -154,9 +154,6 @@ static HRESULT LoadModulePaths( | |||
154 | hr = PathGetDirectory(pState->sczModuleFullPath, &pState->sczAppBase); | 154 | hr = PathGetDirectory(pState->sczModuleFullPath, &pState->sczAppBase); |
155 | BalExitOnFailure(hr, "Failed to get the directory of the full process path."); | 155 | BalExitOnFailure(hr, "Failed to get the directory of the full process path."); |
156 | 156 | ||
157 | hr = PathConcat(pState->sczAppBase, DNC_ASSEMBLY_FILE_NAME, &pState->sczManagedHostPath); | ||
158 | BalExitOnFailure(hr, "Failed to create managed host path."); | ||
159 | |||
160 | LExit: | 157 | LExit: |
161 | return hr; | 158 | return hr; |
162 | } | 159 | } |
@@ -249,7 +246,7 @@ static HRESULT LoadRuntime( | |||
249 | hr = DnchostLoadRuntime( | 246 | hr = DnchostLoadRuntime( |
250 | &pState->hostfxrState, | 247 | &pState->hostfxrState, |
251 | pState->sczModuleFullPath, | 248 | pState->sczModuleFullPath, |
252 | pState->sczManagedHostPath, | 249 | pState->sczBaFactoryAssemblyPath, |
253 | pState->sczBaFactoryDepsJsonPath, | 250 | pState->sczBaFactoryDepsJsonPath, |
254 | pState->sczBaFactoryRuntimeConfigPath); | 251 | pState->sczBaFactoryRuntimeConfigPath); |
255 | 252 | ||
diff --git a/src/ext/Bal/dnchost/dnchost.h b/src/ext/Bal/dnchost/dnchost.h index 22fd8f5e..b0ba9638 100644 --- a/src/ext/Bal/dnchost/dnchost.h +++ b/src/ext/Bal/dnchost/dnchost.h | |||
@@ -23,7 +23,6 @@ struct DNCSTATE | |||
23 | HINSTANCE hInstance; | 23 | HINSTANCE hInstance; |
24 | LPWSTR sczModuleFullPath; | 24 | LPWSTR sczModuleFullPath; |
25 | LPWSTR sczAppBase; | 25 | LPWSTR sczAppBase; |
26 | LPWSTR sczManagedHostPath; | ||
27 | LPWSTR sczBaFactoryAssemblyName; | 26 | LPWSTR sczBaFactoryAssemblyName; |
28 | LPWSTR sczBaFactoryAssemblyPath; | 27 | LPWSTR sczBaFactoryAssemblyPath; |
29 | LPWSTR sczBaFactoryDepsJsonPath; | 28 | LPWSTR sczBaFactoryDepsJsonPath; |
diff --git a/src/ext/Bal/dnchost/dnchost.vcxproj b/src/ext/Bal/dnchost/dnchost.vcxproj index 66e52c6f..1fd2ebed 100644 --- a/src/ext/Bal/dnchost/dnchost.vcxproj +++ b/src/ext/Bal/dnchost/dnchost.vcxproj | |||
@@ -81,14 +81,6 @@ | |||
81 | </ItemDefinitionGroup> | 81 | </ItemDefinitionGroup> |
82 | 82 | ||
83 | <ItemGroup> | 83 | <ItemGroup> |
84 | <ProjectReference Include="..\WixToolset.Dnc.Host\WixToolset.Dnc.Host.csproj"> | ||
85 | <Project>{0D780900-C2FF-4FA2-8CB5-8A19768724C5}</Project> | ||
86 | <ReferenceOutputAssembly>false</ReferenceOutputAssembly> | ||
87 | <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties> | ||
88 | </ProjectReference> | ||
89 | </ItemGroup> | ||
90 | |||
91 | <ItemGroup> | ||
92 | <PackageReference Include="WixToolset.BalUtil" /> | 84 | <PackageReference Include="WixToolset.BalUtil" /> |
93 | 85 | ||
94 | <PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" /> | 86 | <PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" /> |
diff --git a/src/ext/Bal/dnchost/dncutil.cpp b/src/ext/Bal/dnchost/dncutil.cpp index 34d14911..6486e6e9 100644 --- a/src/ext/Bal/dnchost/dncutil.cpp +++ b/src/ext/Bal/dnchost/dncutil.cpp | |||
@@ -2,6 +2,12 @@ | |||
2 | 2 | ||
3 | #include "precomp.h" | 3 | #include "precomp.h" |
4 | 4 | ||
5 | #define DNC_ENTRY_TYPE "WixToolset.Dnc.Host.BootstrapperApplicationFactory" | ||
6 | #define DNC_ENTRY_TYPEW L"WixToolset.Dnc.Host.BootstrapperApplicationFactory" | ||
7 | #define DNC_STATIC_ENTRY_METHOD "CreateBAFactory" | ||
8 | #define DNC_STATIC_ENTRY_METHODW L"CreateBAFactory" | ||
9 | #define DNC_STATIC_ENTRY_DELEGATEW L"WixToolset.Dnc.Host.StaticEntryDelegate" | ||
10 | |||
5 | // https://github.com/dotnet/runtime/blob/master/src/installer/corehost/error_codes.h | 11 | // https://github.com/dotnet/runtime/blob/master/src/installer/corehost/error_codes.h |
6 | #define InvalidArgFailure 0x80008081 | 12 | #define InvalidArgFailure 0x80008081 |
7 | #define HostApiBufferTooSmall 0x80008098 | 13 | #define HostApiBufferTooSmall 0x80008098 |
@@ -74,19 +80,28 @@ LExit: | |||
74 | HRESULT DnchostCreateFactory( | 80 | HRESULT DnchostCreateFactory( |
75 | __in HOSTFXR_STATE* pState, | 81 | __in HOSTFXR_STATE* pState, |
76 | __in LPCWSTR wzBaFactoryAssemblyName, | 82 | __in LPCWSTR wzBaFactoryAssemblyName, |
77 | __in LPCWSTR wzBaFactoryAssemblyPath, | 83 | __in LPCWSTR /*wzBaFactoryAssemblyPath*/, |
78 | __out IBootstrapperApplicationFactory** ppAppFactory | 84 | __out IBootstrapperApplicationFactory** ppAppFactory |
79 | ) | 85 | ) |
80 | { | 86 | { |
81 | HRESULT hr = S_OK; | 87 | HRESULT hr = S_OK; |
82 | PFNCREATEBAFACTORY pfnCreateBAFactory = NULL; | 88 | PFNCREATEBAFACTORY pfnCreateBAFactory = NULL; |
89 | LPWSTR sczEntryType = NULL; | ||
90 | LPWSTR sczEntryDelegate = NULL; | ||
91 | LPSTR sczBaFactoryAssemblyName = NULL; | ||
83 | 92 | ||
84 | if (pState->pfnGetFunctionPointer) | 93 | if (pState->pfnGetFunctionPointer) |
85 | { | 94 | { |
95 | hr = StrAllocFormatted(&sczEntryType, L"%ls,%ls", DNC_ENTRY_TYPEW, wzBaFactoryAssemblyName); | ||
96 | BalExitOnFailure(hr, "Failed to format entry type."); | ||
97 | |||
98 | hr = StrAllocFormatted(&sczEntryDelegate, L"%ls,%ls", DNC_STATIC_ENTRY_DELEGATEW, wzBaFactoryAssemblyName); | ||
99 | BalExitOnFailure(hr, "Failed to format entry delegate."); | ||
100 | |||
86 | hr = pState->pfnGetFunctionPointer( | 101 | hr = pState->pfnGetFunctionPointer( |
87 | DNC_ENTRY_TYPEW, | 102 | sczEntryType, |
88 | DNC_STATIC_ENTRY_METHODW, | 103 | DNC_STATIC_ENTRY_METHODW, |
89 | DNC_STATIC_ENTRY_DELEGATEW, | 104 | sczEntryDelegate, |
90 | NULL, | 105 | NULL, |
91 | NULL, | 106 | NULL, |
92 | reinterpret_cast<void**>(&pfnCreateBAFactory)); | 107 | reinterpret_cast<void**>(&pfnCreateBAFactory)); |
@@ -94,19 +109,26 @@ HRESULT DnchostCreateFactory( | |||
94 | } | 109 | } |
95 | else | 110 | else |
96 | { | 111 | { |
112 | hr = StrAnsiAllocString(&sczBaFactoryAssemblyName, wzBaFactoryAssemblyName, 0, CP_UTF8); | ||
113 | BalExitOnFailure(hr, "Failed to convert assembly name to UTF8: %ls", wzBaFactoryAssemblyName); | ||
114 | |||
97 | hr = pState->pfnCoreclrCreateDelegate( | 115 | hr = pState->pfnCoreclrCreateDelegate( |
98 | pState->pClrHandle, | 116 | pState->pClrHandle, |
99 | pState->dwDomainId, | 117 | pState->dwDomainId, |
100 | DNC_ASSEMBLY_FULL_NAME, | 118 | sczBaFactoryAssemblyName, |
101 | DNC_ENTRY_TYPE, | 119 | DNC_ENTRY_TYPE, |
102 | DNC_STATIC_ENTRY_METHOD, | 120 | DNC_STATIC_ENTRY_METHOD, |
103 | reinterpret_cast<void**>(&pfnCreateBAFactory)); | 121 | reinterpret_cast<void**>(&pfnCreateBAFactory)); |
104 | BalExitOnFailure(hr, "Failed to create delegate in app domain."); | 122 | BalExitOnFailure(hr, "Failed to create delegate in app domain."); |
105 | } | 123 | } |
106 | 124 | ||
107 | *ppAppFactory = pfnCreateBAFactory(wzBaFactoryAssemblyName, wzBaFactoryAssemblyPath); | 125 | *ppAppFactory = pfnCreateBAFactory(); |
108 | 126 | ||
109 | LExit: | 127 | LExit: |
128 | ReleaseStr(sczEntryType); | ||
129 | ReleaseStr(sczEntryDelegate); | ||
130 | ReleaseStr(sczBaFactoryAssemblyName); | ||
131 | |||
110 | return hr; | 132 | return hr; |
111 | } | 133 | } |
112 | 134 | ||
@@ -233,7 +255,7 @@ static HRESULT InitializeCoreClr( | |||
233 | } | 255 | } |
234 | else | 256 | else |
235 | { | 257 | { |
236 | ExitOnFailure(hr, "HostfxrGetRuntimeDelegate failed"); | 258 | BalExitOnFailure(hr, "HostfxrGetRuntimeDelegate failed"); |
237 | } | 259 | } |
238 | 260 | ||
239 | LExit: | 261 | LExit: |
@@ -295,6 +317,8 @@ static HRESULT InitializeCoreClrPre5( | |||
295 | 317 | ||
296 | for (DWORD i = 0; i < cDirectories; ++i) | 318 | for (DWORD i = 0; i < cDirectories; ++i) |
297 | { | 319 | { |
320 | Assert(rgDirectories); | ||
321 | |||
298 | hr = PathConcat(rgDirectories[i], L"coreclr.dll", &sczCoreClrPath); | 322 | hr = PathConcat(rgDirectories[i], L"coreclr.dll", &sczCoreClrPath); |
299 | BalExitOnFailure(hr, "Failed to allocate path to coreclr."); | 323 | BalExitOnFailure(hr, "Failed to allocate path to coreclr."); |
300 | 324 | ||
@@ -324,9 +348,9 @@ static HRESULT InitializeCoreClrPre5( | |||
324 | BalExitOnFailure(hr, "Failed to start coreclr."); | 348 | BalExitOnFailure(hr, "Failed to start coreclr."); |
325 | 349 | ||
326 | LExit: | 350 | LExit: |
327 | MemFree(rgDirectories); | 351 | ReleaseMem(rgDirectories); |
328 | MemFree(rgPropertyValues); | 352 | ReleaseMem(rgPropertyValues); |
329 | MemFree(rgPropertyKeys); | 353 | ReleaseMem(rgPropertyKeys); |
330 | ReleaseStr(sczCoreClrPath); | 354 | ReleaseStr(sczCoreClrPath); |
331 | 355 | ||
332 | return hr; | 356 | return hr; |
diff --git a/src/ext/Bal/dnchost/dncutil.h b/src/ext/Bal/dnchost/dncutil.h index 85eda3b2..f88e3f77 100644 --- a/src/ext/Bal/dnchost/dncutil.h +++ b/src/ext/Bal/dnchost/dncutil.h | |||
@@ -1,10 +1,7 @@ | |||
1 | #pragma once | 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. | 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 | 3 | ||
4 | typedef IBootstrapperApplicationFactory* (STDMETHODCALLTYPE* PFNCREATEBAFACTORY)( | 4 | typedef IBootstrapperApplicationFactory* (STDMETHODCALLTYPE* PFNCREATEBAFACTORY)(); |
5 | __in LPCWSTR wzBaFactoryAssemblyName, | ||
6 | __in LPCWSTR wzBaFactoryAssemblyPath | ||
7 | ); | ||
8 | 5 | ||
9 | struct HOSTFXR_STATE | 6 | struct HOSTFXR_STATE |
10 | { | 7 | { |
diff --git a/src/ext/Bal/dnchost/precomp.h b/src/ext/Bal/dnchost/precomp.h index 84ff6424..7aefc4e3 100644 --- a/src/ext/Bal/dnchost/precomp.h +++ b/src/ext/Bal/dnchost/precomp.h | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <IBootstrapperApplicationFactory.h> | 20 | #include <IBootstrapperApplicationFactory.h> |
21 | #include <balutil.h> | 21 | #include <balutil.h> |
22 | 22 | ||
23 | #include <WixToolset.Dnc.Host.h> | ||
24 | #define NETHOST_USE_AS_STATIC | 23 | #define NETHOST_USE_AS_STATIC |
25 | #include <nethost.h> | 24 | #include <nethost.h> |
26 | #include <hostfxr.h> | 25 | #include <hostfxr.h> |