Fix relocated desktop tool paths and package release 0.2.2

This commit is contained in:
tongtong committed 2026-11-13 12:49:10 +08:00
1 parent efaf16de18
commit e366eb5bec
14 files changed
+250 -33

No files matched your search

@@ -0,0 +1,20 @@
using Ads.Desktop;
using Xunit;
namespace Ads.Desktop.Tests;
public class ToolRelocationTests {
[Fact] public void RelocatedManagedPathUsesCurrentBundle() {
var name="relocate-"+Guid.NewGuid().ToString("N");
var executable=name+(OperatingSystem.IsWindows()?".exe":"");
var bundled=Path.Combine(AppContext.BaseDirectory,executable);
try {
File.WriteAllText(bundled,"fixture");
var old="C:/Users/TT/AppData/Local/Programs/TTSTD/ADS-Avalonia/"+executable;
Assert.Equal(bundled,DesktopPaths.ResolveTool(old,name));
}finally{File.Delete(bundled);}
}
[Fact] public void ValidCustomToolIsPreserved() {
var file=Path.GetTempFileName();
try{Assert.Equal(Path.GetFullPath(file),DesktopPaths.ResolveTool(file,"adb"));}
finally{File.Delete(file);}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup><Version>0.2.1</Version><OutputType>WinExe</OutputType><TargetFramework>net8.0</TargetFramework><Nullable>enable</Nullable><ImplicitUsings>enable</ImplicitUsings></PropertyGroup>
<PropertyGroup><Version>0.2.2</Version><OutputType>WinExe</OutputType><TargetFramework>net8.0</TargetFramework><Nullable>enable</Nullable><ImplicitUsings>enable</ImplicitUsings></PropertyGroup>
<ItemGroup><PackageReference Include="Avalonia.Desktop" Version="11.3.8"/><PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.8"/><PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/></ItemGroup>
<ItemGroup><AvaloniaResource Include="Assets/**"/></ItemGroup></Project>
+4 -2
View File
@@ -104,8 +104,10 @@ public static class DesktopPaths
public static string ResolveTool(string value, string name)
{
value = Environment.ExpandEnvironmentVariables(value.Trim().Trim('"'));
if (File.Exists(value)) return Path.GetFullPath(value);
if (value == name || value == name + ".exe")
var installed = value.Replace('\\', '/');
var managed = System.Text.RegularExpressions.Regex.IsMatch(installed, @"/Programs/(TTSTD|TongTongStudio)/ADS-(Flutter|Avalonia)/", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
if (File.Exists(value) && !managed) return Path.GetFullPath(value);
if (managed || !File.Exists(value))
{
var found = FindTool(name);
if (File.Exists(found)) return Path.GetFullPath(found);
+12
View File
@@ -97,6 +97,18 @@ public partial class MainViewModel : ObservableObject, IDisposable
preferredDevice = settings.PreferredDevice;
}
catch (Exception error) { Log("读取配置失败,使用默认值:" + error.Message); }
if (File.Exists(settingsFile)) {
var changed=false;
string Repair(string value,string name) {
try {
var resolved=DesktopPaths.ResolveTool(value,name);
if(resolved!=value){changed=true;Log($"已更新 {name} 工具位置:{resolved}");}
return resolved;
} catch(InvalidOperationException) { return value; }
}
ClientPath=Repair(ClientPath,"ads-client");AdbPath=Repair(AdbPath,"adb");ScrcpyPath=Repair(ScrcpyPath,"scrcpy");
if(changed)PersistSelectedPaths();
}
var environmentToken = loadLocalCredentials ? Environment.GetEnvironmentVariable("ADS_CLIENT_TOKEN") : null;
if (!string.IsNullOrWhiteSpace(environmentToken))
{
+2
View File
@@ -96,3 +96,5 @@ USB 会话后端已按操作系统选择:Windows 使用已签名 USBip 控制
桌面日志界面提供“打开日志文件夹”。Avalonia 与 Flutter 均按天保存日志,单文件达到 5 MiB 后滚动,每日最多 5 份,保留最近 14 天。设备列表显示所属电脑及 Agent。Windows 安装包默认安装到 `%LOCALAPPDATA%/Programs/TongTongStudio/ADS-{Edition}`;用户配置和日志位置保持兼容。升级保持原 AppId,安装目录不再自动沿用旧的 TTSTD 路径。
Windows 自包含发布把托管程序集打包到主程序,保留原生图形 DLL 和独立 Rust/ADB/scrcpy 工具;不启用反射裁剪,不要求安装 .NET,也不将全部应用压为单文件。发布使用全新暂存目录。`Ads.Desktop.exe --package-check` 可在隔离配置、无设备连接和不占用正式客户端互斥锁的条件下创建窗口后退出,用于验证发布包。
升级安装目录后会修复保存的旧工具位置;有效自定义可执行文件保留。启动时将解析后的路径写回已有设置,避免仍使用已删除的 TTSTD 安装目录。