packServer/desktop/YuncangTrace.LocalService.csproj
liufumingren c280e94b9a 加固局域网询问应答:主体 + 后端身份双校验
主体 id 在各环境的库里都从 1 开始,光比 subjectId 挡不住跨环境串台
(开发库和生产库的测试仓库都是 1),旧机器只要 agent.json 还在就会一直应答。

- 询问必须带 subjectId>0 和 server,缺任一项不应答
- 应答回带 server,A 侧也校验一致;不一致直接丢弃
- 多台应答按 (SN, 主机) 去重,并优先本机地址
- 版本号提到 1.0.105

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-22 01:27:49 +08:00

118 lines
6.0 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!-- WPF 只能跑在 Windows 上;net8.0-windows 是当前 LTS -->
<TargetFramework>net8.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<!-- 托盘图标用 WinForms 的 NotifyIcon(WPF 没有内置托盘) -->
<UseWindowsForms>true</UseWindowsForms>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<!--
⚠️ 必须关掉隐式 using:WPF 与 WinForms 同时开启时,两边的隐式命名空间会让
MessageBox / Application / Clipboard / Point 等类型产生歧义(编译不过)。
各文件里显式 using 自己需要的命名空间。
-->
<ImplicitUsings>disable</ImplicitUsings>
<ApplicationIcon>Assets\app.ico</ApplicationIcon>
<!-- 产物名/程序集名(安装包里 exe 就叫这个) -->
<AssemblyName>YuncangTrace.LocalService</AssemblyName>
<RootNamespace>YuncangTrace.LocalService</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<!--
WFAC010:WinForms 分析器建议把高 DPI 从 manifest 挪到 ApplicationHighDpiMode。
但本程序是 WPF 宿主(走的是 WPF 的 App.Run,不会调 WinForms 的 ApplicationConfiguration),
WinForms 只用来放托盘图标 —— 那条建议在这里不生效,DPI 只能由 manifest 的 PerMonitorV2 决定。
-->
<NoWarn>$(NoWarn);WFAC010</NoWarn>
<!--
环境配置(和前端 VITE_BACKEND 一个思路:由构建决定,不靠用户手填)
Debug :AppEnvironment=Development,默认后端 http://127.0.0.1:7300(= 前端 dev 代理的地址)
Release :AppEnvironment=Production ,默认后端由 -p:ServerBaseUrl=https://正式域名 覆盖
运行时覆盖优先级:命令行 server 参数 &gt; YUNCANG_SERVER 环境变量 &gt; 这里注入的默认值。
-->
<AppEnvironment Condition="'$(Configuration)' == 'Debug'">Development</AppEnvironment>
<AppEnvironment Condition="'$(Configuration)' == 'Release'">Production</AppEnvironment>
<ServerBaseUrl Condition="'$(Configuration)' == 'Debug' and '$(ServerBaseUrl)' == ''">http://127.0.0.1:7300</ServerBaseUrl>
<ServerBaseUrl Condition="'$(Configuration)' == 'Release' and '$(ServerBaseUrl)' == ''">https://packs.example.com</ServerBaseUrl>
<Version>1.0.105</Version>
<Product>云仓视频溯源软件</Product>
<Company>云仓</Company>
<AssemblyTitle>云仓视频溯源软件(本机服务)</AssemblyTitle>
<NeutralLanguage>zh-CN</NeutralLanguage>
<!--
同一个 exe 三种身份:桌面端 / Windows 服务(service 参数)/ 提权 helper(agent-control 参数)。
入口在 Program.cs;不写 StartupObject 的话 WPF 自动生成的 Main 会和它冲突(CS0017)。
-->
<StartupObject>YuncangTrace.LocalService.Program</StartupObject>
</PropertyGroup>
<!-- 把环境写进程序集(Services/BuildInfo.cs 运行时读出来) -->
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>AppEnvironment</_Parameter1>
<_Parameter2>$(AppEnvironment)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>ServerBaseUrl</_Parameter1>
<_Parameter2>$(ServerBaseUrl)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
<!--
海康「设备网络 SDK(HCNetSDK Win64)」运行库,随程序输出到 native\HCNetSDK\。
运行时会按 环境变量 YUNCANG_HIKSDK_DIR → 程序目录\native\HCNetSDK → 程序目录 的顺序查找 HCNetSDK.dll。
这里用通配符,SDK 升级时只要替换目录内容即可,不用改工程。
-->
<ItemGroup>
<Content Include="native\HCNetSDK\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<!--
⚠️ 必须排除单文件打包:默认会被塞进 exe 内部(自解压),
安装包只装 exe 时看似没问题,但 exe 体积暴涨且 native 目录不存在,
HCNetSDK 的依赖(HCCore.dll / HCNetSDKCom\*)解析会变得不可控。
显式让它作为**独立文件**输出到 publish\native\HCNetSDK\,由 MSI 一起安装。
-->
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<!--
ffmpeg(随程序输出到 native\ffmpeg\ffmpeg.exe):回放校验 / 录像合并 / 主码流转 MJPEG 都靠它。
之前没打进安装包,客户机必须自己装 ffmpeg,非服务端电脑就下不了合并后的成片。
同样要 ExcludeFromSingleFile —— 200MB+ 的单文件静态 exe 塞进自解压包没有意义。
运行时查找顺序:YUNCANG_FFMPEG → <exe目录>\native\ffmpeg\ffmpeg.exe → PATH
-->
<Content Include="native\ffmpeg\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<!--
谷歌浏览器插件(仓库根目录 extension\):随程序输出到 native 同级的 extension\,
安装后位于 <安装目录>\extension,菜单「工具 → 复制谷歌插件地址」直接给出该 Windows 路径,
用户在 chrome://extensions 里「加载已解压的扩展程序」即可。
开发调试文件(test\ / tools\)不打进安装包。
-->
<Content Include="..\extension\**\*" Exclude="..\extension\test\**;..\extension\tools\**">
<Link>extension\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
</ItemGroup>
</Project>