适配WindowsVista编译 (#499)

This commit is contained in:
nilaoda 2024-11-22 19:46:34 +08:00 committed by GitHub
parent bb20d50122
commit c004a1c72f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 41 additions and 32 deletions

View File

@ -23,7 +23,7 @@ env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
jobs:
build-win7-x86:
build-win-nt6_0-x86:
runs-on: windows-latest
steps:
@ -34,13 +34,15 @@ jobs:
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}
- run: powershell -Command "(Get-Content src/N_m3u8DL-RE/N_m3u8DL-RE.csproj) -replace '<TargetFramework>.*</TargetFramework>', '<TargetFramework>net9.0-windows</TargetFramework>' | Set-Content src/N_m3u8DL-RE/N_m3u8DL-RE.csproj"
- run: dotnet add src/N_m3u8DL-RE/N_m3u8DL-RE.csproj package YY-Thunks --version 1.1.4
- run: dotnet add src/N_m3u8DL-RE/N_m3u8DL-RE.csproj package VC-LTL --version 5.1.1
- run: dotnet publish src/N_m3u8DL-RE -r win-x86 -c Release -o artifact-x86
- run: dotnet publish src/N_m3u8DL-RE -p:TargetPlatformMinVersion=6.0 -r win-x86 -c Release -o artifact-x86
- name: Upload Artifact[win-x86]
uses: actions/upload-artifact@v3.1.3
with:
name: N_m3u8DL-RE_Beta_win7-x86
name: N_m3u8DL-RE_Beta_win_NT6.0-x86
path: artifact-x86\N_m3u8DL-RE.exe
build-win-x64-arm64:
@ -135,7 +137,7 @@ jobs:
create_draft_release:
name: Create Github draft release
if: ${{ github.event.inputs.doRelease == 'true' }}
needs: [build-win7-x86,build-win-x64-arm64,build-linux-x64,build-linux-arm64,build-mac-x64-arm64]
needs: [build-win-nt6_0-x86,build-win-x64-arm64,build-linux-x64,build-linux-arm64,build-mac-x64-arm64]
runs-on: ubuntu-latest
steps:
- name: Audit gh version

View File

@ -5,7 +5,7 @@
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>N_m3u8DL_RE.Common</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

View File

@ -2,6 +2,8 @@
public class ResString
{
public static string CurrentLoc = "en-US";
public static readonly string ReLiveTs = "<RE_LIVE_TS>";
public static string singleFileRealtimeDecryptWarn => GetText("singleFileRealtimeDecryptWarn");
public static string singleFileSplitWarn => GetText("singleFileSplitWarn");
@ -132,10 +134,9 @@ public class ResString
if (!StaticText.LANG_DIC.ContainsKey(key))
return "<...LANG TEXT MISSING...>";
var current = Thread.CurrentThread.CurrentUICulture.Name;
if (current == "zh-CN" || current == "zh-SG" || current == "zh-Hans")
if (CurrentLoc == "zh-CN" || CurrentLoc == "zh-SG" || CurrentLoc == "zh-Hans")
return StaticText.LANG_DIC[key].ZH_CN;
if (current.StartsWith("zh-"))
if (CurrentLoc.StartsWith("zh-"))
return StaticText.LANG_DIC[key].ZH_TW;
return StaticText.LANG_DIC[key].EN_US;
}

View File

@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>library</OutputType>
<OutputType>library</OutputType>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>N_m3u8DL_RE.Parser</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

View File

@ -5,18 +5,18 @@
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies>
<StaticallyLinked Condition="$(RuntimeIdentifier.StartsWith('win'))">true</StaticallyLinked>
<TrimMode>full</TrimMode>
<TrimmerDefaultAction>link</TrimmerDefaultAction>
<IlcTrimMetadata>true</IlcTrimMetadata>
<IlcGenerateStackTraceData>true</IlcGenerateStackTraceData>
<SatelliteResourceLanguages>zh-CN;zh-TW;en-US</SatelliteResourceLanguages>
<PublishAot>true</PublishAot>
<StripSymbols>true</StripSymbols>
<ObjCopyName Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">aarch64-linux-gnu-objcopy</ObjCopyName>
<TrimmerDefaultAction>link</TrimmerDefaultAction>
<IlcTrimMetadata>true</IlcTrimMetadata>
<IlcGenerateStackTraceData>true</IlcGenerateStackTraceData>
<SatelliteResourceLanguages>zh-CN;zh-TW;en-US</SatelliteResourceLanguages>
<PublishAot>true</PublishAot>
<StripSymbols>true</StripSymbols>
<ObjCopyName Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">aarch64-linux-gnu-objcopy</ObjCopyName>
</PropertyGroup>
<!-- <ItemGroup Condition="'$(PublishAot)' == 'true' and '$(RuntimeIdentifier)' != 'win-arm64' and '$(RuntimeIdentifier)' != 'linux-arm64' and '$(RuntimeIdentifier)' != 'osx-arm64' and '$(RuntimeIdentifier)' != 'osx-x64'">
<PackageReference Include="PublishAotCompressed" Version="1.0.3" />
</ItemGroup> -->
<!--<ItemGroup Condition="'$(PublishAot)' == 'true' and '$(RuntimeIdentifier)' != 'win-arm64' and '$(RuntimeIdentifier)' != 'linux-arm64' and '$(RuntimeIdentifier)' != 'osx-arm64' and '$(RuntimeIdentifier)' != 'osx-x64'">
<PackageReference Include="PublishAotCompressed" Version="1.0.3" />
</ItemGroup>-->
<ItemGroup>
<RdXmlFile Include="rd.xml" />

View File

@ -2,13 +2,13 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>N_m3u8DL_RE</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<Version>0.2.1</Version>
<Platforms>AnyCPU;x64</Platforms>
<Version>0.2.1</Version>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>

View File

@ -5,7 +5,6 @@ using N_m3u8DL_RE.Parser;
using Spectre.Console;
using N_m3u8DL_RE.Common.Resource;
using N_m3u8DL_RE.Common.Log;
using System.Globalization;
using System.Text;
using N_m3u8DL_RE.Common.Util;
using N_m3u8DL_RE.Processor;
@ -22,11 +21,21 @@ internal class Program
{
static async Task Main(string[] args)
{
// 处理NT6.0及以下System.CommandLine报错CultureNotFound问题
if (OperatingSystem.IsWindows())
{
var osVersion = Environment.OSVersion.Version;
if (osVersion.Major < 6 || (osVersion.Major == 6 && osVersion.Minor == 0))
{
Environment.SetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1");
}
}
Console.CancelKeyPress += Console_CancelKeyPress;
ServicePointManager.DefaultConnectionLimit = 1024;
try { Console.CursorVisible = true; } catch { }
string loc = "en-US";
string loc = ResString.CurrentLoc;
string currLoc = Thread.CurrentThread.CurrentUICulture.Name;
if (currLoc == "zh-CN" || currLoc == "zh-SG") loc = "zh-CN";
else if (currLoc.StartsWith("zh-")) loc = "zh-TW";
@ -39,10 +48,7 @@ internal class Program
loc = list[index + 1];
}
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(loc);
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(loc);
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(loc);
ResString.CurrentLoc = loc;
await CommandInvoker.InvokeArgs(args, DoWorkAsync);
}