Skip to content

Commit

Permalink
Pass build with WixToolset v5
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir Bar authored and nirbar committed Apr 14, 2024
1 parent e094ae8 commit c7da347
Show file tree
Hide file tree
Showing 21 changed files with 118 additions and 242 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/github-actions-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
psw_wix_version:
description: 'PanelSwWix4 version'
required: true
default: 5.0.0-psw-wix.0265-49
default: 6.0.0-psw-wix.0267-11
type: string

jobs:
Expand All @@ -37,7 +37,7 @@ jobs:
Add-Content -Path ${{ github.env }} -Value "PSW_WIX_VERSION=${{ env.DEFAULT_PSW_WIX_VERSION }}"
}
env:
DEFAULT_PSW_WIX_VERSION: '5.0.0-psw-wix.0265-49'
DEFAULT_PSW_WIX_VERSION: '6.0.0-psw-wix.0267-11'

- name: Prepare for build
run: |
Expand All @@ -61,11 +61,11 @@ jobs:
if-no-files-found: error

- name: Publish nuget packages to github and nuget.org
if: ${{ github.event.inputs.publish_nuget == 'true' && github.ref == 'refs/heads/master4' }}
if: ${{ github.event.inputs.publish_nuget == 'true' && github.ref == 'refs/heads/master5' }}
env:
GITHUB_TOKEN: ${{ secrets.TAGGER_PAT }}
run: |
dotnet nuget push nuget-out\PanelSwWixExtension4.*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source github
dotnet nuget push nuget-out\PanelSwWixExtension4.*.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
git tag "wix4-v${{ env.FULL_VERSION }}"
git tag "wix5-v${{ env.FULL_VERSION }}"
git push --tags
6 changes: 5 additions & 1 deletion .github/workflows/publish-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ jobs:
run: |
$sdkFileName = Get-Childitem –Path "PanelSwWixExtension4.*.nupkg" -Exclude "*-psw-wix*" -Name
if ($sdkFileName) {
Add-Content -Path ${{ github.env }} -Value ("WIX_VERSION=wix4")
if ($sdkFileName.StartsWith("PanelSwWixExtension4.5")) {
Add-Content -Path ${{ github.env }} -Value ("WIX_VERSION=wix5")
} else {
Add-Content -Path ${{ github.env }} -Value ("WIX_VERSION=wix4")
}
$sdkFileName = $sdkFileName.Replace("PanelSwWixExtension4.", "");
}
else {
Expand Down
8 changes: 4 additions & 4 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<Wix4Version Condition=" '$(Wix4Version)' == '' ">4.0.5</Wix4Version>
<PanelSwWix4Version Condition=" '$(PanelSwWix4Version)' == '' ">5.0.0-psw-wix.0265-49</PanelSwWix4Version>
<Wix4Version Condition=" '$(Wix4Version)' == '' ">5.0.0</Wix4Version>
<PanelSwWix4Version Condition=" '$(PanelSwWix4Version)' == '' ">6.0.0-psw-wix.0267-11</PanelSwWix4Version>
<SevenZapVersion Condition=" '$(SevenZapVersion)' == '' ">23.1.33</SevenZapVersion>
</PropertyGroup>
<ItemGroup>
Expand All @@ -17,7 +17,7 @@
<PackageVersion Include="WixToolset.BalUtil" Version="$(Wix4Version)" />
<PackageVersion Include="WixToolset.BootstrapperCore.Native" Version="$(Wix4Version)" />
<PackageVersion Include="WixToolset.NetFx.wixext" Version="$(Wix4Version)" />
<PackageVersion Include="WixToolset.BextUtil" Version="$(Wix4Version)" />
<PackageVersion Include="WixToolset.BootstrapperExtensionApi" Version="$(Wix4Version)" />
<PackageVersion Include="PanelSwWix4.DUtil" version="$(PanelSwWix4Version)" />
<PackageVersion Include="PanelSwWix4.WcaUtil" version="$(PanelSwWix4Version)" />
<PackageVersion Include="PanelSwWix4.Extensibility" Version="$(PanelSwWix4Version)" />
Expand All @@ -29,7 +29,7 @@
<PackageVersion Include="PanelSwWix4.BalUtil" Version="$(PanelSwWix4Version)" />
<PackageVersion Include="PanelSwWix4.BootstrapperCore.Native" Version="$(PanelSwWix4Version)" />
<PackageVersion Include="PanelSwWix4.NetFx.wixext" Version="$(PanelSwWix4Version)" />
<PackageVersion Include="PanelSwWix4.BextUtil" Version="$(PanelSwWix4Version)" />
<PackageVersion Include="PanelSwWix4.BootstrapperExtensionApi" Version="$(PanelSwWix4Version)" />
<PackageVersion Include="TidyBuild" version="1.5.2" />
<PackageVersion Include="Microsoft.Web.Administration" Version="11.1.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.2" />
Expand Down
36 changes: 18 additions & 18 deletions src/PanelSwBackendExtension/PanelSwBackendExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#include "PanelSwBackendExtension.h"
#include "PanelSwZipContainer.h"
#include "PanelSwLzmaContainer.h"
#include <BextBaseBundleExtensionProc.h>
#include <BextBaseBootstrapperExtensionProc.h>
using namespace std;

CPanelSwBundleExtension::CPanelSwBundleExtension(IBundleExtensionEngine* pEngine)
: CBextBaseBundleExtension(pEngine)
CPanelSwBundleExtension::CPanelSwBundleExtension(IBootstrapperExtensionEngine* pEngine)
: CBextBaseBootstrapperExtension(pEngine)
{
XmlInitialize();
}
Expand All @@ -24,10 +24,10 @@ STDMETHODIMP CPanelSwBundleExtension::Search(LPCWSTR wzId, LPCWSTR wzVariable)
CComPtr<IXMLDOMNode> pixnBundleExtension;
CComBSTR bszXml;

hr = XmlLoadDocumentFromFile(m_sczBundleExtensionDataPath, &pixdManifest);
BextExitOnFailure(hr, "Failed to load bundle extension manifest from path: %ls", m_sczBundleExtensionDataPath);
hr = XmlLoadDocumentFromFile(m_sczBootstrapperExtensionDataPath, &pixdManifest);
BextExitOnFailure(hr, "Failed to load bundle extension manifest from path: %ls", m_sczBootstrapperExtensionDataPath);

hr = BextGetBundleExtensionDataNode(pixdManifest, PANELSW_BACKEND_EXTENSION_ID, &pixnBundleExtension);
hr = BextGetBootstrapperExtensionDataNode(pixdManifest, PANELSW_BACKEND_EXTENSION_ID, &pixnBundleExtension);
BextExitOnFailure(hr, "Failed to get BundleExtensionData entry for '%ls'", PANELSW_BACKEND_EXTENSION_ID);

hr = pixnBundleExtension->get_xml(&bszXml);
Expand Down Expand Up @@ -63,10 +63,10 @@ HRESULT CPanelSwBundleExtension::CreateContainer(LPCWSTR wzContainerId, IPanelSw
LPWSTR szXPath = nullptr;
IPanelSwContainer* pContainer = nullptr;

hr = XmlLoadDocumentFromFile(m_sczBundleExtensionDataPath, &pixdManifest);
BextExitOnFailure(hr, "Failed to load bundle extension manifest from path: %ls", m_sczBundleExtensionDataPath);
hr = XmlLoadDocumentFromFile(m_sczBootstrapperExtensionDataPath, &pixdManifest);
BextExitOnFailure(hr, "Failed to load bundle extension manifest from path: %ls", m_sczBootstrapperExtensionDataPath);

hr = BextGetBundleExtensionDataNode(pixdManifest, PANELSW_BACKEND_EXTENSION_ID, &pixnBundleExtension);
hr = BextGetBootstrapperExtensionDataNode(pixdManifest, PANELSW_BACKEND_EXTENSION_ID, &pixnBundleExtension);
BextExitOnFailure(hr, "Failed to get BundleExtension '%ls'", PANELSW_BACKEND_EXTENSION_ID);

hr = StrAllocFormatted(&szXPath, L"PSW_ContainerExtensionData[@ContainerId='%ls']/@Compression", wzContainerId);
Expand Down Expand Up @@ -152,7 +152,7 @@ STDMETHODIMP CPanelSwBundleExtension::ContainerNextStream(LPVOID pContext, BSTR*

hr = GetContainer(pContext, &pContainer);
BextExitOnFailure(hr, "Failed to get container");

hr = pContainer->ContainerNextStream(psczStreamName);

LExit:
Expand Down Expand Up @@ -257,35 +257,35 @@ HRESULT CPanelSwBundleExtension::ReleaseContainer(IPanelSwContainer* pContainer)
return hr;
}

extern "C" HRESULT WINAPI BundleExtensionCreate(
__in const BUNDLE_EXTENSION_CREATE_ARGS * pArgs,
__inout BUNDLE_EXTENSION_CREATE_RESULTS * pResults
extern "C" HRESULT WINAPI BootstrapperExtensionCreate(
__in const BOOTSTRAPPER_EXTENSION_CREATE_ARGS* pArgs,
__inout BOOTSTRAPPER_EXTENSION_CREATE_RESULTS* pResults
)
{
HRESULT hr = S_OK;
IBundleExtensionEngine* pEngine = nullptr;
IBootstrapperExtensionEngine* pEngine = nullptr;
CPanelSwBundleExtension* pExtension = nullptr;

hr = BextInitializeFromCreateArgs(pArgs, &pEngine);
ExitOnFailure(hr, "Failed to initialize bext");
BextLog(BUNDLE_EXTENSION_LOG_LEVEL_STANDARD, "Loading Panel::Software bundle extension v" FullVersion);
BextLog(BOOTSTRAPPER_EXTENSION_LOG_LEVEL_STANDARD, "Loading Panel::Software bundle extension v" FullVersion);

pExtension = new CPanelSwBundleExtension(pEngine);
BextExitOnNull(pExtension, hr, E_OUTOFMEMORY, "Failed to create new CPanelSwBundleExtension.");

hr = pExtension->Initialize(pArgs);
BextExitOnFailure(hr, "CPanelSwBundleExtension initialization failed.");

pResults->pfnBundleExtensionProc = BextBaseBundleExtensionProc;
pResults->pvBundleExtensionProcContext = pExtension;
pResults->pfnBootstrapperExtensionProc = BextBaseBootstrapperExtensionProc;
pResults->pvBootstrapperExtensionProcContext = pExtension;

LExit:
ReleaseObject(pEngine);

return hr;
}

extern "C" void WINAPI BundleExtensionDestroy()
extern "C" void WINAPI BootstrapperExtensionDestroy()
{
BextUninitialize();
}
4 changes: 2 additions & 2 deletions src/PanelSwBackendExtension/PanelSwBackendExtension.def
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LIBRARY "PanelSwBackendExtension"

EXPORTS
BundleExtensionCreate
BundleExtensionDestroy
BootstrapperExtensionCreate
BootstrapperExtensionDestroy
4 changes: 2 additions & 2 deletions src/PanelSwBackendExtension/PanelSwBackendExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include "pch.h"
#include <list>

class CPanelSwBundleExtension : public CBextBaseBundleExtension
class CPanelSwBundleExtension : public CBextBaseBootstrapperExtension
{
public:
CPanelSwBundleExtension(IBundleExtensionEngine* pEngine);
CPanelSwBundleExtension(IBootstrapperExtensionEngine* pEngine);

virtual ~CPanelSwBundleExtension();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<PackageReference Include="TidyBuild" />
<PackageReference Include="7Zap" />
<PackageReference Include="WixToolset.DUtil" />
<PackageReference Include="WixToolset.BextUtil" />
<PackageReference Include="WixToolset.BootstrapperExtensionApi" />
<PackageReference Include="WixToolset.WcaUtil" />
</ItemGroup>
<ItemGroup>
Expand Down
56 changes: 11 additions & 45 deletions src/PanelSwBackendExtension/PanelSwLzmaContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,11 @@ HRESULT CPanelSwLzmaContainer::Init(LPCWSTR wzContainerId, HANDLE hBundle, DWORD
openOpts.excludedFormats = new CIntVector();
openOpts.props = new CObjectVector<CProperty>();

for (unsigned i = 0; i < MAX_RETRIES; ++i)
{
hr = S_OK;

hr = inStream->InitContainer(hBundle, qwContainerStartPos, qwContainerSize);
if (FAILED(hr))
{
BextLogError(hr, "Failed to open container stream on attempt %u/%u", i, MAX_RETRIES);
continue;
}

hr = _archive->OpenStream(openOpts);
if (FAILED(hr))
{
BextLogError(hr, "Failed to open container on attempt %u/%u", i, MAX_RETRIES);
continue;
}
if (_archive->Archive == nullptr)
{
hr = E_FAIL;
BextLogError(hr, "Failed to initialize container on attempt %u/%u", i, MAX_RETRIES);
continue;
}

break;
}
hr = inStream->InitContainer(hBundle, qwContainerStartPos, qwContainerSize);
BextExitOnFailure(hr, "Failed to open container");

hr = _archive->OpenStream(openOpts);
BextExitOnFailure(hr, "Failed to open container stream");
BextExitOnNull(_archive->Archive, hr, E_FAIL, "Failed to initialize container");

hr = _archive->Archive->GetNumberOfItems(&_entryCount);
Expand Down Expand Up @@ -131,7 +109,7 @@ HRESULT CPanelSwLzmaContainer::ContainerOpen(LPCWSTR wzContainerId, LPCWSTR wzFi
hr = Init(wzContainerId, hFile, 0, CPanelSwLzmaInStream::INFINITE_CONTAINER_SIZE);
BextExitOnFailure(hr, "Failed to open container '%ls'", wzFilePath);

BextLog(BUNDLE_EXTENSION_LOG_LEVEL_STANDARD, "Openned 7Z container '%ls'", wzFilePath);
BextLog(BOOTSTRAPPER_EXTENSION_LOG_LEVEL_STANDARD, "Openned 7Z container '%ls'", wzFilePath);

LExit:
ReleaseFileHandle(hFile);
Expand All @@ -146,7 +124,7 @@ HRESULT CPanelSwLzmaContainer::ContainerOpenAttached(LPCWSTR wzContainerId, HAND
hr = Init(wzContainerId, hBundle, qwContainerStartPos, qwContainerSize);
BextExitOnFailure(hr, "Failed to open container '%ls'", wzContainerId);

BextLog(BUNDLE_EXTENSION_LOG_LEVEL_STANDARD, "Openned 7Z attached container '%ls'", wzContainerId);
BextLog(BOOTSTRAPPER_EXTENSION_LOG_LEVEL_STANDARD, "Openned 7Z attached container '%ls'", wzContainerId);

LExit:
return hr;
Expand Down Expand Up @@ -242,24 +220,12 @@ HRESULT CPanelSwLzmaContainer::ContainerStreamToFileNow(UInt32 nFileIndex, LPCWS
BextExitOnNull(pExtractCallback, hr, E_OUTOFMEMORY, "Failed to allocate extract callback object");
extractClbk = pExtractCallback;

for (unsigned i = 0; i < MAX_RETRIES; ++i)
{
hr = S_OK;

hr = pExtractCallback->Init(_archive->Archive, 1, &nFileIndex, &targetFile);
BextExitOnFailure(hr, "Failed to initialize extract callbck");
hr = pExtractCallback->Init(_archive->Archive, 1, &nFileIndex, &targetFile);
BextExitOnFailure(hr, "Failed to initialize extract callbck");

hr = _archive->Archive->Extract(&nFileIndex, 1, 0, extractClbk);
if (FAILED(hr))
{
BextLogError(hr, "Failed to extract files on attempt %u/%u", i, MAX_RETRIES);
continue;
}

break;
}
BextExitOnFailure(hr, "Failed to extract files");
BextExitOnNull(!pExtractCallback->HasErrors(), hr, E_FAIL, "Failed to extract files");
hr = _archive->Archive->Extract(&nFileIndex, 1, 0, extractClbk);
BextExitOnFailure(hr, "Failed to extract '%ls'", wzFileName);
BextExitOnNull(!pExtractCallback->HasErrors(), hr, E_FAIL, "Failed to extract '%ls'", wzFileName);

LExit:
return S_OK;
Expand Down
33 changes: 6 additions & 27 deletions src/PanelSwBackendExtension/PanelSwLzmaInStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ void CPanelSwLzmaInStream::ReleaseContainer()
_qwBundleSize = 0;
}

Z7_COM7F_IMF(CPanelSwLzmaInStream::Read(void* data, UInt32 size, UInt32* processedSize))
Z7_COM7F_IMF(CPanelSwLzmaInStream::Read(void* pData, UInt32 size, UInt32* processedSize))
{
HRESULT hr = S_OK;
LARGE_INTEGER llPos;
LARGE_INTEGER llCurrPos;
LARGE_INTEGER llMaxRead;
UInt32 uiRead = 0;
DWORD dwRead = 0;
BOOL bRes = TRUE;

llPos.QuadPart = 0;
Expand All @@ -71,35 +71,14 @@ Z7_COM7F_IMF(CPanelSwLzmaInStream::Read(void* data, UInt32 size, UInt32* process
llMaxRead.QuadPart = size;
}

for (unsigned i = 0; (uiRead < llMaxRead.QuadPart) && (i < MAX_RETRIES); ++i)
{
DWORD dwCurrRead = 0;
unsigned char* pData = (unsigned char*)data;

bRes = ::ReadFile(_hBundle, pData + uiRead, llMaxRead.LowPart - uiRead, &dwCurrRead, nullptr);
if (!bRes)
{
hr = HRESULT_FROM_WIN32(::GetLastError());
BextLogError(hr, "Failed to read on attempt %u/%u", i, MAX_RETRIES);
continue;
}
uiRead += dwCurrRead;
if (uiRead < llMaxRead.QuadPart)
{
hr = HRESULT_FROM_WIN32(ERROR_READ_FAULT);
BextLogError(hr, "Failed to read sufficient data on attempt %u/%u. Read %u/%I64u bytes", i, MAX_RETRIES, uiRead, llMaxRead.QuadPart);
continue;
}

hr = S_OK;
break;
}
BextExitOnFailure(hr, "Failed to read from container");
bRes = ::ReadFile(_hBundle, pData, llMaxRead.LowPart, &dwRead, nullptr);
BextExitOnNullWithLastError(bRes, hr, "Failed to read from 7z archive");
BextExitOnNull((dwRead == llMaxRead.LowPart), hr, E_FAIL, "Failed to read sufficient data from 7z archive. Read %u/%u bytes", dwRead, llMaxRead.LowPart);

LExit:
if (processedSize)
{
*processedSize = uiRead;
*processedSize = dwRead;
}

return hr;
Expand Down
33 changes: 16 additions & 17 deletions src/PanelSwBackendExtension/PanelSwLzmaInStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,28 @@ Z7_class_final(CPanelSwLzmaInStream) :
public IStreamGetSize,
public CMyUnknownImp
{
Z7_COM_UNKNOWN_IMP_2(
IInStream,
IStreamGetSize)
Z7_COM_UNKNOWN_IMP_2(
IInStream,
IStreamGetSize)

Z7_IFACE_COM7_IMP(ISequentialInStream)
Z7_IFACE_COM7_IMP(IInStream)

Z7_IFACE_COM7_IMP(ISequentialInStream)
Z7_IFACE_COM7_IMP(IInStream)
public:
Z7_IFACE_COM7_IMP(IStreamGetSize)
Z7_IFACE_COM7_IMP(IStreamGetSize);

public:
virtual ~CPanelSwLzmaInStream();
virtual ~CPanelSwLzmaInStream();

HRESULT InitContainer(HANDLE hBundle, DWORD64 qwContainerStartPos, DWORD64 qwContainerSize);

static const DWORD64 INFINITE_CONTAINER_SIZE = (~(DWORD64)0);
HRESULT InitContainer(HANDLE hBundle, DWORD64 qwContainerStartPos, DWORD64 qwContainerSize);

private:
void ReleaseContainer();
static const DWORD64 INFINITE_CONTAINER_SIZE = (~(DWORD64)0);

static unsigned const MAX_RETRIES = 10;
private:
void ReleaseContainer();

HANDLE _hBundle = INVALID_HANDLE_VALUE;
DWORD64 _qwContainerStartPos = 0;
DWORD64 _qwContainerSize = 0;
DWORD64 _qwBundleSize = 0;
HANDLE _hBundle = INVALID_HANDLE_VALUE;
DWORD64 _qwContainerStartPos = 0;
DWORD64 _qwContainerSize = 0;
DWORD64 _qwBundleSize = 0;
};
Loading

0 comments on commit c7da347

Please sign in to comment.