ARM dll, verbose installer
This commit is contained in:
Yu Chieh Victor Lin 2024-04-19 15:37:15 +08:00
parent 534b91c064
commit da9cc0a9d7
6 changed files with 55 additions and 45 deletions

View File

@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<LangVersion>12</LangVersion>
<ProjectGuid>{64467D32-4786-4ADD-9B77-FBF3C965D3D1}</ProjectGuid>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Community.PowerToys.Run.Plugin.Everything</RootNamespace>
@ -10,22 +11,24 @@
<Version>$([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)plugin.json').Split(',')[5].Split(':')[1].Trim().Trim('"'))</Version>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<GenerateSatelliteAssembliesForCore>true</GenerateSatelliteAssembliesForCore>
<Company>lin-ycv</Company>
<Copyright>Copyright (C) lin-ycv</Copyright>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateSatelliteAssembliesForCore>true</GenerateSatelliteAssembliesForCore>
<Company>lin-ycv</Company>
<Copyright>Copyright (C) lin-ycv</Copyright>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\$(Platform)\$(Configuration)\Everything\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
<OutputPath>bin\$(Platform)\$(Configuration)\Everything\</OutputPath>
<Optimize>true</Optimize>
<DebugType>none</DebugType>
</PropertyGroup>
@ -83,6 +86,9 @@
<None Update="Everything64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="EverythingARM64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\Everything.dark.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@ -139,7 +145,7 @@
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="del /Q &quot;$(TargetDir)*.pdb&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)PowerToys*.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)Wox*.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)Ijwhost.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)*.xml&quot;&#xD;&#xA;del/ Q &quot;$(TargetDir)backup_restore_settings.json&quot;&#xD;&#xA;del /Q &quot;.\bin\CHECKSUM.txt&quot;&#xD;&#xA;powershell Compress-Archive -Path $(TargetDir) -DestinationPath .\bin\EverythingPT-$(Version)-x64.zip -Force&#xD;&#xA;&quot;C:\Program Files (x86)\NSIS\makensis&quot; /Dver=$(Version) /Ddirect=$(TargetDir) .\NSIS\exeCreator.nsi&#xD;&#xA;certUtil -hashfile .\bin\EverythingPT-$(Version)-x64.zip SHA256 &gt;&gt; .\bin\CHECKSUM.txt&#xD;&#xA;certUtil -hashfile .\bin\EverythingPT-$(Version)-x64.exe SHA256 &gt;&gt; .\bin\CHECKSUM.txt" />
<Exec Command="del /Q &quot;$(TargetDir)*.pdb&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)PowerToys*.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)Wox*.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)Ijwhost.dll&quot;&#xD;&#xA;del /Q &quot;$(TargetDir)*.xml&quot;&#xD;&#xA;del/ Q &quot;$(TargetDir)backup_restore_settings.json&quot;&#xD;&#xA;del /Q &quot;.\bin\CHECKSUM.txt&quot;&#xD;&#xA;powershell Compress-Archive -Path $(TargetDir) -DestinationPath .\bin\EverythingPT-$(Version)-x64+ARM64.zip -Force&#xD;&#xA;&quot;C:\Program Files (x86)\NSIS\makensis&quot; /Dver=$(Version) /Ddirect=$(TargetDir) .\NSIS\exeCreator.nsi&#xD;&#xA;certUtil -hashfile .\bin\EverythingPT-$(Version)-x64+ARM64.zip SHA256 &gt;&gt; .\bin\CHECKSUM.txt&#xD;&#xA;certUtil -hashfile .\bin\EverythingPT-$(Version)-x64+ARM64.exe SHA256 &gt;&gt; .\bin\CHECKSUM.txt&#xD;&#xA;rd /Q /S &quot;$(TargetDir)&quot;&#xD;&#xA;rd &quot;$(ProjectDir)obj&quot; /s /q" />
</Target>
</Project>

View File

@ -106,8 +106,6 @@ namespace Community.PowerToys.Run.Plugin.Everything.Interop
#endregion
internal const string dllName = "Everything64.dll";
[LibraryImport(dllName)]
internal static partial uint Everything_GetLastError();
[LibraryImport(dllName)]
internal static partial uint Everything_GetNumResults();
[LibraryImport(dllName, EntryPoint = "Everything_GetResultFullPathNameW", StringMarshalling = StringMarshalling.Utf16)]
internal static partial uint Everything_GetResultFullPathName(uint nIndex, [Out] char[] lpString, uint nMaxCount);

23
Main.cs
View File

@ -1,4 +1,5 @@
using Microsoft.PowerToys.Settings.UI.Library;
using System.Runtime.InteropServices;
using Microsoft.PowerToys.Settings.UI.Library;
namespace Community.PowerToys.Run.Plugin.Everything
{
@ -92,8 +93,28 @@ namespace Community.PowerToys.Run.Plugin.Everything
},
};
private void CheckArm()
{
string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
arm = Path.Combine(dir, "EverythingARM64.dll");
if (File.Exists(arm))
{
Architecture arch = RuntimeInformation.ProcessArchitecture;
if (arch == Architecture.Arm64)
{
File.Delete(Path.Combine(dir, "Everything64.dll"));
File.Move(arm, Path.Combine(dir, "Everything64.dll"));
}
else
{
File.Delete(arm);
}
}
}
public void Init(PluginInitContext context)
{
CheckArm();
if (_setting.Updates)
Task.Run(() => new Update().UpdateAsync(Assembly.GetExecutingAssembly().GetName().Version, _setting));
_everything = new Everything(_setting);

View File

@ -1,4 +1,4 @@
; Silent switch /S/
; Silent switch /S
; Pass in /Dver=0.00.0 before calling the script to set the version
; ie: makensis /Dver=0.77.0 .\exeCreator.nsi
; Doc: https://nsis.sourceforge.io/Docs/Chapter4.html
@ -19,50 +19,33 @@ LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
BrandingText "${EPT} v${ver}"
CRCCheck force
FileErrorText "Can't write: $\r$\n$\r$\n$0$\r$\n$\r$\nPowerToys is probaly still running, please close it and retry."
Icon Everything.ico
InstallDir "$LOCALAPPDATA\Microsoft\PowerToys\PowerToys Run\Plugins\Everything"
Name "${EPT}"
OutFile ".\..\bin\${EPT}-${ver}-x64.exe"
OutFile ".\..\bin\${EPT}-${ver}-x64+ARM64.exe"
RequestExecutionLevel user
SetCompressor /SOLID /FINAL lzma
Unicode True
;--------------------------------
Page directory
;Page directory
Page instfiles
;--------------------------------
Section ""
;ExecWait '"$%SystemRoot%\system32\TaskKill.exe" /F /IM ${PT}'
ClearErrors
SetOutPath $INSTDIR
GetFullPathName $0 "$EXEDIR\"
GetFullPathName $0 $0
File /r "${direct}\*"
IfFileExists "$LOCALAPPDATA\PowerToys\${PT}" 0 +2
Exec '"$LOCALAPPDATA\PowerToys\${PT}"'
IfFileExists "$PROGRAMFILES64\PowerToys\${PT}" 0 +2
Exec '"$PROGRAMFILES64\PowerToys\${PT}"'
IfErrors 0 +5
SetErrorlevel 2
IfSilent +2
MessageBox MB_ICONEXCLAMATION "Unable to install, PowerToys is probaly still running, please close it manually before install."
Abort
SectionEnd
;--------------------------------
Function .onInit
ExecWait 'wmic process where name="${PT}" call terminate'
ExecWait 'wmic process where name="PowerToys.PowerLauncher.exe" call terminate'
Sleep 200
; System::Call 'kernel32::CreateMutex(p 0, i 0, t "ACFEF7F6-7856-4BB3-82E3-0877CBB4E9C7") p .r1 ?e'
; Pop $R0
; StrCmp $R0 0 +3
; MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
; Abort
FunctionEnd
SectionEnd

View File

@ -3,7 +3,7 @@
public class Settings
{
// Settings from PTR settings
public Interop.NativeMethods.Sort Sort { get; set; } = Interop.NativeMethods.Sort.DATE_MODIFIED_DESCENDING;
public Sort Sort { get; set; } = Sort.DATE_MODIFIED_DESCENDING;
public uint Max { get; set; } = 20;
public string Context { get; set; } = "012345";
public bool Copy { get; set; }

View File

@ -37,12 +37,14 @@ namespace Community.PowerToys.Run.Plugin.Everything
}
}
byte[] fileContent = await httpClient.GetByteArrayAsync(nameUrl[1]);
string fileName = Path.Combine(Path.GetTempPath(), nameUrl[0]);
File.WriteAllBytes(fileName, fileContent);
using Process updater = Process.Start(fileName);
updater.WaitForExit(5000);
if (updater.ExitCode == 1)
if (nameUrl[0].Length > 0)
{
byte[] fileContent = await httpClient.GetByteArrayAsync(nameUrl[1]);
string fileName = Path.Combine(Path.GetTempPath(), nameUrl[0]);
File.WriteAllBytes(fileName, fileContent);
Process.Start(fileName);
}
else
{
ProcessStartInfo p = new("https://github.com/lin-ycv/EverythingPowerToys/releases/latest")
{