mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-01 01:10:34 +08:00
build: Update to .NET 10 (#14971)
* build: Update to .NET 10 * chore: 关闭 CET 保证 win10 可用性 * feat: 提升语言版本 * chore: 更新文档与脚本 * chore: update all packages * fix: 修复 GpuOption 构建错误 * chore: 更新依赖安装脚本 * chore: 更新 csproj 中标记的软件版本 * docs: Update docs/zh-cn/develop/development.md Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> * docs: Update docs/zh-tw/develop/development.md Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --------- Co-authored-by: uye <99072975+ABA2396@users.noreply.github.com> Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
This commit is contained in:
@@ -58,7 +58,7 @@ We've preset several different development environments for you to choose from:
|
||||
```
|
||||
|
||||
5. Configure development environment
|
||||
- Download and install `Visual Studio 2022 Community`, selecting `Desktop development with C++` and `.NET Desktop Development` during installation.
|
||||
- Download and install `Visual Studio 2026 Community`, selecting `Desktop development with C++` and `.NET Desktop Development` during installation.
|
||||
|
||||
6. Double-click `MAA.sln` to open the project in Visual Studio.
|
||||
7. Configure Visual Studio settings
|
||||
|
||||
@@ -64,7 +64,7 @@ icon: iconoir:developer
|
||||
```
|
||||
|
||||
5. 開発環境の設定
|
||||
- `Visual Studio 2022 Community` をインストール時、`C++ によるデスクトップ開発` と `.NET デスクトップ開発` を選択必須
|
||||
- `Visual Studio 2026 Community` をインストール時、`C++ によるデスクトップ開発` と `.NET デスクトップ開発` を選択必須
|
||||
|
||||
6. `MAA.sln` をダブルクリックで開き、Visual Studio にプロジェクトを自動ロード
|
||||
7. VS の設定
|
||||
|
||||
@@ -63,7 +63,7 @@ icon: iconoir:developer
|
||||
```
|
||||
|
||||
5. 개발 환경 구성
|
||||
- Visual Studio 2022 Community 설치 시 `C++ 데스크톱 개발` 및 `.NET 데스크톱 개발` 필수 선택
|
||||
- Visual Studio 2026 Community 설치 시 `C++ 데스크톱 개발` 및 `.NET 데스크톱 개발` 필수 선택
|
||||
|
||||
6. MAA.sln 파일 더블클릭 → Visual Studio에서 프로젝트 자동 로드
|
||||
7. VS 설정
|
||||
|
||||
@@ -59,13 +59,13 @@ icon: iconoir:developer
|
||||
|
||||
5. 配置编程环境
|
||||
- 下载并安装 `CMake`
|
||||
- 下载并安装 `Visual Studio 2022 community`, 安装的时候需要选中 `基于 C++ 的桌面开发` 和 `.NET 桌面开发`。
|
||||
- 下载并安装 `Visual Studio 2026 Community`, 安装的时候需要选中 `基于 C++ 的桌面开发` 和 `.NET 桌面开发`。
|
||||
|
||||
6. 执行 cmake 项目配置
|
||||
|
||||
```cmd
|
||||
mkdir -p build
|
||||
cmake -G "Visual Studio 17 2022" -B build -DBUILD_WPF_GUI=ON -DBUILD_DEBUG_DEMO=ON
|
||||
cmake -G "Visual Studio 18 2026" -B build -DBUILD_WPF_GUI=ON -DBUILD_DEBUG_DEMO=ON
|
||||
```
|
||||
|
||||
7. 双击打开 `build/MAA.sln` 文件,Visual Studio 会自动加载整个项目。
|
||||
|
||||
@@ -58,7 +58,7 @@ icon: iconoir:developer
|
||||
```
|
||||
|
||||
5. 配置編程環境
|
||||
- 下載並安裝 `Visual Studio 2022 community`, 安裝的時候需要選中 `基於 C++ 的桌面開發` 和 `.NET 桌面開發`。
|
||||
- 下載並安裝 `Visual Studio 2026 Community`, 安裝的時候需要選中 `基於 C++ 的桌面開發` 和 `.NET 桌面開發`。
|
||||
|
||||
6. 雙擊打開 `MAA.sln` 文件,Visual Studio 會自動載入整個項目。
|
||||
7. 設置 VS
|
||||
|
||||
@@ -230,7 +230,7 @@ public abstract class GpuOption
|
||||
|
||||
var interfacePath = req.adapterDevicePath.ToString();
|
||||
uint size = 0;
|
||||
var err = PInvoke.CM_Get_Device_Interface_Property(interfacePath, PInvoke.DEVPKEY_Device_InstanceId, out var type, null, ref size, 0);
|
||||
var err = PInvoke.CM_Get_Device_Interface_Property(interfacePath, PInvoke.DEVPKEY_Device_InstanceId, out var type, Span<byte>.Empty, ref size, 0);
|
||||
|
||||
if (err != CONFIGRET.CR_BUFFER_SMALL)
|
||||
{
|
||||
@@ -245,16 +245,23 @@ public abstract class GpuOption
|
||||
var buf = ArrayPool<byte>.Shared.Rent((int)size);
|
||||
string? result;
|
||||
|
||||
fixed (byte* ptr = buf)
|
||||
try
|
||||
{
|
||||
err = PInvoke.CM_Get_Device_Interface_Property(interfacePath, PInvoke.DEVPKEY_Device_InstanceId, out _, ptr, ref size, 0);
|
||||
err = PInvoke.CM_Get_Device_Interface_Property(interfacePath, PInvoke.DEVPKEY_Device_InstanceId, out _, buf.AsSpan(0, (int)size), ref size, 0);
|
||||
if (err != CONFIGRET.CR_SUCCESS)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var cch = (int)(size / 2) - 1;
|
||||
result = Marshal.PtrToStringUni((nint)ptr, cch);
|
||||
fixed (byte* ptr = buf)
|
||||
{
|
||||
result = Marshal.PtrToStringUni((nint)ptr, cch);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ArrayPool<byte>.Shared.Return(buf);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -311,7 +318,8 @@ public abstract class GpuOption
|
||||
System.Runtime.InteropServices.ComTypes.FILETIME ft;
|
||||
uint size = (uint)sizeof(System.Runtime.InteropServices.ComTypes.FILETIME);
|
||||
|
||||
var err = PInvoke.CM_Get_DevNode_Property(devInst, PInvoke.DEVPKEY_Device_DriverDate, out _, (byte*)(&ft), ref size, 0);
|
||||
var ftSpan = new Span<byte>(&ft, (int)size);
|
||||
var err = PInvoke.CM_Get_DevNode_Property(devInst, PInvoke.DEVPKEY_Device_DriverDate, out _, ftSpan, ref size, 0);
|
||||
|
||||
if (err != CONFIGRET.CR_SUCCESS)
|
||||
{
|
||||
@@ -321,7 +329,7 @@ public abstract class GpuOption
|
||||
var driverDate = ft.ToDateTime().Date;
|
||||
|
||||
size = 0;
|
||||
err = PInvoke.CM_Get_DevNode_Property(devInst, PInvoke.DEVPKEY_Device_DriverVersion, out _, null, ref size, 0);
|
||||
err = PInvoke.CM_Get_DevNode_Property(devInst, PInvoke.DEVPKEY_Device_DriverVersion, out _, Span<byte>.Empty, ref size, 0);
|
||||
|
||||
if (err != CONFIGRET.CR_BUFFER_SMALL)
|
||||
{
|
||||
@@ -330,10 +338,14 @@ public abstract class GpuOption
|
||||
|
||||
var buf = new byte[size];
|
||||
string? driverVersion;
|
||||
err = PInvoke.CM_Get_DevNode_Property(devInst, PInvoke.DEVPKEY_Device_DriverVersion, out _, buf.AsSpan(), ref size, 0);
|
||||
if (err != CONFIGRET.CR_SUCCESS)
|
||||
{
|
||||
return new(description, null, driverDate);
|
||||
}
|
||||
|
||||
fixed (byte* ptr = buf)
|
||||
{
|
||||
// err =
|
||||
PInvoke.CM_Get_DevNode_Property(devInst, PInvoke.DEVPKEY_Device_DriverVersion, out _, ptr, ref size, 0);
|
||||
driverVersion = Marshal.PtrToStringUni((nint)ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- Project -->
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
|
||||
<TargetFramework>net10.0-windows10.0.17763.0</TargetFramework>
|
||||
<RuntimeIdentifier Condition="$(Platform)=='x64'">win-x64</RuntimeIdentifier>
|
||||
<RuntimeIdentifier Condition="$(Platform)=='ARM64'">win-arm64</RuntimeIdentifier>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<StartupObject>MaaWpfGui.App</StartupObject>
|
||||
<LangVersion>12</LangVersion>
|
||||
<LangVersion>14</LangVersion>
|
||||
<UseWpf>true</UseWpf>
|
||||
<Configurations>Debug;Release;RelWithDebInfo</Configurations>
|
||||
<Platforms>ARM64;x64</Platforms>
|
||||
@@ -38,12 +38,13 @@
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<CETCompat>false</CETCompat>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Version -->
|
||||
<PropertyGroup>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>5.0.0.0</ApplicationVersion>
|
||||
<ApplicationVersion>6.0.0.0</ApplicationVersion>
|
||||
<Version>0.0.1</Version>
|
||||
<FileVersion>0.0.1</FileVersion>
|
||||
<AssemblyVersion>0.0.1</AssemblyVersion>
|
||||
@@ -109,43 +110,42 @@
|
||||
<PackageReference Include="CalcBinding" Version="2.5.2" />
|
||||
<PackageReference Include="FluentEmail.Liquid" Version="3.0.2" />
|
||||
<PackageReference Include="FluentEmail.MailKit" Version="3.0.2" />
|
||||
<PackageReference Include="Fody" Version="6.8.0">
|
||||
<PackageReference Include="Fody" Version="6.9.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="GlobalHotKey" Version="1.1.0">
|
||||
<NoWarn>NU1701</NoWarn>
|
||||
</PackageReference>
|
||||
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
|
||||
<PackageReference Include="HandyControls" Version="3.5.2" />
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
|
||||
<PackageReference Include="MdXaml" Version="1.22.0" />
|
||||
<PackageReference Include="MdXaml.Html" Version="1.22.0" />
|
||||
<PackageReference Include="MdXaml.Plugins" Version="1.22.0" />
|
||||
<PackageReference Include="gong-wpf-dragdrop" Version="4.0.0" />
|
||||
<PackageReference Include="HandyControls" Version="3.6.0" />
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4" />
|
||||
<PackageReference Include="MdXaml" Version="1.27.0" />
|
||||
<PackageReference Include="MdXaml.Html" Version="1.27.0" />
|
||||
<PackageReference Include="MdXaml.Plugins" Version="1.27.0" />
|
||||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
|
||||
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.183">
|
||||
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.259">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Notification.Wpf" Version="7.0.0.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
<PackageReference Include="Notification.Wpf" Version="8.0.0" />
|
||||
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.5" />
|
||||
<PackageReference Include="ObservableCollections" Version="1.1.3" />
|
||||
<PackageReference Include="ObservableCollections" Version="3.3.4" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Semver" Version="3.0.0" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
|
||||
<PackageReference Include="Serilog" Version="4.3.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Thread" Version="4.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Stylet" Version="1.3.6" />
|
||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
|
||||
<PackageReference Include="VirtualizingWrapPanel" Version="2.2.1" />
|
||||
<PackageReference Include="WindowsAPICodePack" Version="8.0.6" />
|
||||
<PackageReference Include="Stylet" Version="1.3.7" />
|
||||
<PackageReference Include="System.Management" Version="10.0.0" />
|
||||
<PackageReference Include="VirtualizingWrapPanel" Version="2.3.2" />
|
||||
<PackageReference Include="WindowsAPICodePack" Version="8.0.12" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -43,11 +43,11 @@ echo %BLUE%=====================================================================
|
||||
|
||||
echo.
|
||||
echo %BLUE%====================================================================================================%RESET%
|
||||
echo %BOLD%%CYAN%正在安装 .NET Desktop Runtime 8.0%RESET%
|
||||
echo %BOLD%%CYAN%Installing .NET Desktop Runtime 8.0%RESET%
|
||||
echo %BOLD%%CYAN%正在安装 .NET Desktop Runtime 10.0%RESET%
|
||||
echo %BOLD%%CYAN%Installing .NET Desktop Runtime 10.0%RESET%
|
||||
echo.
|
||||
|
||||
winget install "Microsoft.DotNet.DesktopRuntime.8" --override "/repair /passive /norestart" --uninstall-previous --accept-package-agreements --force
|
||||
winget install "Microsoft.DotNet.DesktopRuntime.10" --override "/repair /passive /norestart" --uninstall-previous --accept-package-agreements --force
|
||||
if %errorlevel% neq 0 (
|
||||
set "ErrorOccurred=1"
|
||||
)
|
||||
@@ -72,8 +72,8 @@ if %ErrorOccurred% equ 0 (
|
||||
echo %WHITE%Microsoft Visual C++ Redistributable:%RESET%
|
||||
echo %CYAN%https://aka.ms/vs/17/release/vc_redist.x64.exe%RESET%
|
||||
echo.
|
||||
echo %WHITE%.NET Desktop Runtime 8.0:%RESET%
|
||||
echo %CYAN%https://aka.ms/dotnet/8.0/windowsdesktop-runtime-win-x64.exe%RESET%
|
||||
echo %WHITE%.NET Desktop Runtime 10.0:%RESET%
|
||||
echo %CYAN%https://aka.ms/dotnet/10.0/windowsdesktop-runtime-win-x64.exe%RESET%
|
||||
echo %RED%====================================================================================================%RESET%
|
||||
)
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
cd ..
|
||||
cmake -G "Visual Studio 17 2022" -B build -DBUILD_WPF_GUI=ON -DBUILD_DEBUG_DEMO=ON
|
||||
cmake -G "Visual Studio 18 2026" -B build -DBUILD_WPF_GUI=ON -DBUILD_DEBUG_DEMO=ON
|
||||
pause
|
||||
Reference in New Issue
Block a user