packServer/desktop/YuncangTrace.LocalService.csproj
liufumingren fe8c0d62a1 chore(ports): 本机服务与边缘代理端口整体迁出 173xx
- 桌面端本机 HTTP/WS:17300/17301 → 16000/16001(前端、浏览器扩展、文档同步)
- 后台服务局域网:UDP 17310/TCP 17311 → UDP 16100/TCP 16101(16010 被向日葵占用,统一避开 160xx)
- 防火墙规则随端口更新,安装/升级时清理旧 17xxx 规则,避免继续占用别人的端口
- 桌面端版本升到 1.0.162

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-18 15:51:41 +08:00

141 lines
7.7 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.162</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\dist\):随程序输出到 native 同级的 extension\,
安装后位于 <安装目录>\extension,菜单「工具 → 复制插件路径(开发者模式)」给出该 Windows 路径;
正式分发走企业策略(菜单「工具 → 安装谷歌插件」),crx/updates.xml 由 npm run extension:publish 发布。
⚠️ 打进安装包的是**压缩后的 dist**(`npm run extension:bundle` 生成,体积约源码 1/3,
已去注释、压空白;不做混淆 —— MV3 的 CSP 禁止 eval,商店也要求代码可读)。
桌面端 build.ps1 在 dotnet publish 之前会自动跑一次;本地单独编译时先执行
`cd backend && npm run extension:bundle`,否则会打到上一次的 dist。
⚠️ 这些**绝对不能**打进安装包:
· keys\ 扩展签名私钥(泄漏 = 别人能签一个"官方更新"推给我们的客户)
· out\ 打包产物(crx/updates.xml,客户端从服务器拉)
· test\ tools\ 开发调试文件(bundle 时已被排除,不在 dist 里)
-->
<Content Include="..\extension\dist\**\*"
Exclude="..\extension\dist\keys\**;..\extension\dist\out\**">
<Link>extension\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
<PropertyGroup>
<!-- OpenCvSharp 4.13 自带的 Roslyn 分析器是针对更高版本编译器构建的,在当前 SDK 下每次编译
都会报 CS9057(分析器/编译器版本不匹配)。我们只把它当普通库调用、不用它的分析器,
所以按项目关掉这一条警告(ExcludeAssets="analyzers" 对部分 SDK 版本不生效,用 NoWarn 兜底)。 -->
<NoWarn>$(NoWarn);CS9057</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
<PackageReference Include="ZXing.Net" Version="0.16.10" />
<!-- 条码检测(contrib 的 cv::barcode 模块):4.13 起 OpenCvSharp 才封装 BarcodeDetector。
实测 1920x1080 整图检测约 10~15ms,能直接给出条码的四角点(带旋转/透视),
透视矫正后交给 ZXing 解 Code128。 -->
<PackageReference Include="OpenCvSharp4" Version="4.13.0.20260627" ExcludeAssets="analyzers" />
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.13.0.20260627" />
</ItemGroup>
</Project>