Skip to content

Commit

Permalink
fix: fixed empty files in zip, removed hidden console window
Browse files Browse the repository at this point in the history
  • Loading branch information
dady8889 committed Mar 29, 2022
1 parent 9fe8c4b commit d15272f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
24 changes: 14 additions & 10 deletions Onova.Installer/Onova.Installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ int main(int argc, char* argv[])
cout << "WARNING: Your terminal does not support Unicode characters." << endl;
}

#ifdef NDEBUG
// hide the console window
ShowWindow(GetConsoleWindow(), SW_HIDE);
#endif
//#ifdef NDEBUG
// // hide the console window
// ShowWindow(GetConsoleWindow(), SW_HIDE);
//#endif

#ifndef NDEBUG
wcout << "Attach debugger" << endl;
Expand Down Expand Up @@ -70,10 +70,10 @@ int main(int argc, char* argv[])
}

// show the window
ShowWindow(GetConsoleWindow(), SW_SHOW);
// ShowWindow(GetConsoleWindow(), SW_SHOW);

wcout << L"Welcome to " << data.AppName << L" web install" << endl;
wcout << L"Downloading the latest version..." << endl;
wcout << L"Checking manifest..." << endl;

// read the manifest
ManifestMap manifestMap;
Expand All @@ -100,7 +100,7 @@ int main(int argc, char* argv[])
return 1;
}

wcout << L"Installing version " << ConvertAnsiToWide(newestEntry->first) << L"..." << endl;
wcout << L"Downloading version " << ConvertAnsiToWide(newestEntry->first) << L"..." << endl;

wstring tempZipPath;

Expand All @@ -114,6 +114,8 @@ int main(int argc, char* argv[])
wcout << L"Written zip to: " << tempZipPath << endl;
#endif

wcout << L"Unpacking..." << endl;

// unpack the zip
DWORD unpackedSize;
wstring startupFilePath;
Expand Down Expand Up @@ -226,10 +228,12 @@ bool LoadPublisherData(wstring selfFilePath, PublisherData_t* publisherData)
// parse the structure
char* pointer = buffer;

publisherData->AppName = std::wstring(reinterpret_cast<wchar_t*>(pointer), PUBLISHER_DATA_APPNAME_LEN / sizeof(wchar_t));
size_t appNameSize = wcsnlen_s(reinterpret_cast<wchar_t*>(pointer), PUBLISHER_DATA_APPNAME_LEN / sizeof(wchar_t));
publisherData->AppName = std::wstring(reinterpret_cast<wchar_t*>(pointer), appNameSize);
pointer += PUBLISHER_DATA_APPNAME_LEN;

publisherData->ManifestUrl = std::string(pointer, PUBLISHER_DATA_MANIFESTURL_LEN);
size_t urlSize = strnlen_s(pointer, PUBLISHER_DATA_MANIFESTURL_LEN);
publisherData->ManifestUrl = std::string(pointer, urlSize);
pointer += PUBLISHER_DATA_MANIFESTURL_LEN;

return true;
Expand Down Expand Up @@ -653,7 +657,7 @@ bool UninstallApp(wstring selfFilePath, UninstallerData_t* uninstallerData)

void PrintError(wstring message)
{
ShowWindow(GetConsoleWindow(), SW_SHOW);
// ShowWindow(GetConsoleWindow(), SW_SHOW);
wcerr << message << endl;
system("pause");
}
3 changes: 2 additions & 1 deletion Onova.Installer/unzip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4189,7 +4189,8 @@ ZRESULT TUnzip::Unzip(int index,void *dst,unsigned int len,DWORD flags)
if (res>0) {DWORD writ; BOOL bres=WriteFile(h,unzbuf,res,&writ,NULL); if (!bres) {haderr=ZR_WRITE; break;}}
#endif
if (reached_eof) break;
if (res==0) {haderr=ZR_FLATE; break;}
// if (res==0) {haderr=ZR_FLATE; break;}
if (res == 0) break; // allow empty files
}
unzCloseCurrentFile(uf);
#ifdef ZIP_STD
Expand Down
3 changes: 2 additions & 1 deletion Onova.Publisher.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
<group targetFramework="net6.0" />
</dependencies>
<releaseNotes>* FIX: Fixed order of versions placed in manifest during rebuild.
* FIX: Fixed installing zips with empty files.
* NEW: Added Unicode support for the application name.
* NEW: Code signing support using -s or --sign. Read more in Onova.Publisher -h.
* CHANGE: Output argument -o or --output will now output generated files to the specified directory. (previously it would always create OnovaPublish folder)
* CHANGE: Maximum length of application name is now 31 characters, url is 1023 characters.
</releaseNotes>
</metadata>
<files>
<file src="Onova.Publisher\publish\**" target="tools/"/>
<file src=".\publish\**" target="tools/"/>
</files>
</package>
10 changes: 9 additions & 1 deletion Onova.Publisher/Onova.Publisher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@
<PackageReference Include="System.CommandLine.Rendering" Version="0.3.0-alpha.21216.1" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent;Publish">
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<ItemGroup>
<SignToolFiles Include="$(NuGetPackageRoot)signtool\10.0.17763.132\tools\*.*" />
</ItemGroup>
<Copy SourceFiles="$(SolutionDir)bin\Onova.Installer\$(ConfigurationName)\Win32\Onova.Installer.exe" DestinationFolder="$(TargetDir)" />
<Copy SourceFiles="@(SignToolFiles)" DestinationFolder="$(TargetDir)" />
</Target>

<Target Name="PostPublish" AfterTargets="Publish">
<ItemGroup>
<SignToolFiles Include="$(NuGetPackageRoot)signtool\10.0.17763.132\tools\*.*" />
</ItemGroup>
<Copy SourceFiles="$(SolutionDir)bin\Onova.Installer\$(ConfigurationName)\Win32\Onova.Installer.exe" DestinationFolder="$(PublishDir)" />
<Copy SourceFiles="@(SignToolFiles)" DestinationFolder="$(PublishDir)" />
</Target>
</Project>

0 comments on commit d15272f

Please sign in to comment.