update build config

This commit is contained in:
Genteure 2020-12-21 19:08:44 +08:00
parent d5f6914da4
commit ba370d84de
16 changed files with 71 additions and 295 deletions

View File

@ -15,7 +15,7 @@ insert_final_newline = true
indent_size = 2
[.csproj]
[*.csproj]
indent_size = 2

View File

@ -1,24 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>9.0</LangVersion>
<StartupObject>BililiveRecorder.Cli.Program</StartupObject>
</PropertyGroup>
<PropertyGroup>
<RuntimeIdentifiers>win-x64;osx.10.11-x64;linux-arm64;linux-arm;linux-x64</RuntimeIdentifiers>
<PublishDir Condition=" '$(RuntimeIdentifier)' == '' ">publish\any</PublishDir>
<PublishDir Condition=" '$(RuntimeIdentifier)' != '' ">publish\$(RuntimeIdentifier)</PublishDir>
<SelfContained Condition=" '$(RuntimeIdentifier)' == '' ">false</SelfContained>
<SelfContained Condition=" '$(SelfContained)' == '' ">true</SelfContained>
</PropertyGroup>
<ItemGroup>
<None Remove="config.json" />
<None Remove="NLog.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\TempBuildInfo\BuildInfo.Cli.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@ -27,22 +26,17 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
<PackageReference Include="CommandLineParser" Version="2.4.3" />
<PackageReference Include="NLog" Version="4.7.6" />
<PackageReference Include="NLog.Config" Version="4.7.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BililiveRecorder.Core\BililiveRecorder.Core.csproj" />
<ProjectReference Include="..\BililiveRecorder.FlvProcessor\BililiveRecorder.FlvProcessor.csproj" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="cd $(SolutionDir)&#xD;&#xA;powershell -ExecutionPolicy Bypass -File .\CI\patch_buildinfo.ps1 Cli" />
</Target>
</Project>

View File

@ -1,5 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -13,57 +13,55 @@ using NLog;
namespace BililiveRecorder.Cli
{
class Program
internal class Program
{
private static IContainer Container { get; set; }
private static ILifetimeScope RootScope { get; set; }
private static IRecorder Recorder { get; set; }
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
static void Main(string[] _)
private static void Main(string[] _)
{
var builder = new ContainerBuilder();
builder.RegisterModule<FlvProcessorModule>();
builder.RegisterModule<CoreModule>();
builder.RegisterType<CommandConfigV1>().As<ConfigV1>().InstancePerMatchingLifetimeScope("recorder_root");
Container = builder.Build();
var Container = builder.Build();
var RootScope = Container.BeginLifetimeScope("recorder_root");
RootScope = Container.BeginLifetimeScope("recorder_root");
Recorder = RootScope.Resolve<IRecorder>();
if (!Recorder.Initialize(System.IO.Directory.GetCurrentDirectory()))
var Recorder = RootScope.Resolve<IRecorder>();
if (!Recorder.Initialize(Directory.GetCurrentDirectory()))
{
Console.WriteLine("Initialize Error");
return;
}
Parser.Default
.ParseArguments<CommandConfigV1>(() => (CommandConfigV1)Recorder.Config, Environment.GetCommandLineArgs())
.ParseArguments(() => (CommandConfigV1)Recorder.Config, Environment.GetCommandLineArgs())
.WithParsed(Run);
}
private static void Run(ConfigV1 option)
{
option.EnabledFeature = EnabledFeature.RecordOnly;
foreach (var room in option.RoomList)
return;
void Run(ConfigV1 option)
{
if (Recorder.Where(r => r.RoomId == room.Roomid).Count() == 0)
option.EnabledFeature = EnabledFeature.RecordOnly;
foreach (var room in option.RoomList)
{
Recorder.AddRoom(room.Roomid);
if (Recorder.Where(r => r.RoomId == room.Roomid).Count() == 0)
{
Recorder.AddRoom(room.Roomid);
}
}
}
logger.Info("Using workDir: " + option.WorkDirectory + "\n\tconfig: " + JsonConvert.SerializeObject(option, Formatting.Indented));
logger.Info("开始录播");
Task.WhenAll(Recorder.Select(x => Task.Run(() => x.Start()))).Wait();
Console.CancelKeyPress += (sender, e) =>
{
Task.WhenAll(Recorder.Select(x => Task.Run(() => x.StopRecord()))).Wait();
logger.Info("停止录播");
};
while (true)
{
Thread.Sleep(TimeSpan.FromSeconds(10));
logger.Info("Using workDir: " + option.WorkDirectory + "\n\tconfig: " + JsonConvert.SerializeObject(option, Formatting.Indented));
logger.Info("开始录播");
Task.WhenAll(Recorder.Select(x => Task.Run(() => x.Start()))).Wait();
Console.CancelKeyPress += (sender, e) =>
{
Task.WhenAll(Recorder.Select(x => Task.Run(() => x.StopRecord()))).Wait();
logger.Info("停止录播");
};
while (true)
{
Thread.Sleep(TimeSpan.FromSeconds(10));
}
}
}
}
@ -76,52 +74,44 @@ namespace BililiveRecorder.Cli
set
{
var roomids = value.Split(',');
RoomList.Clear();
this.RoomList.Clear();
foreach (var roomid in roomids)
{
var room = new RoomV1();
room.Roomid = Int32.Parse(roomid);
room.Roomid = int.Parse(roomid);
room.Enabled = false;
RoomList.Add(room);
this.RoomList.Add(room);
}
}
}
[Option('o', "dir", Default = ".", HelpText = "Output directory", Required = false)]
public new string WorkDirectory
{
get { return base.WorkDirectory; }
set { base.WorkDirectory = value; }
get => base.WorkDirectory;
set => base.WorkDirectory = value;
}
[Option("cookie", HelpText = "Provide custom cookies", Required = false)]
public new string Cookie
{
get { return base.Cookie; }
set { base.Cookie = value; }
}
[Option("avoidtxy", HelpText = "Avoid Tencent Cloud server", Required = false)]
public new bool AvoidTxy
{
get { return base.AvoidTxy; }
set { base.AvoidTxy = value; }
get => base.Cookie;
set => base.Cookie = value;
}
[Option("live_api_host", HelpText = "Use custom api host", Required = false)]
public new string LiveApiHost
{
get { return base.LiveApiHost; }
set { base.LiveApiHost = value; }
get => base.LiveApiHost;
set => base.LiveApiHost = value;
}
[Option("record_filename_format", HelpText = "Recording name format", Required = false)]
public new string RecordFilenameFormat
{
get { return base.RecordFilenameFormat; }
set { base.RecordFilenameFormat = value; }
get => base.RecordFilenameFormat;
set => base.RecordFilenameFormat = value;
}
}
}
}

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Debug</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\DebugPublish\any</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\ReleasePublish\any</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Debug</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\DebugPublish\linux-arm</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\ReleasePublish\linux-arm</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Debug</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\DebugPublish\linux-arm64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>linux-arm64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\ReleasePublish\linux-arm64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>linux-arm64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Debug</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\DebugPublish\linux-x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\ReleasePublish\linux-x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Debug</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\DebugPublish\osx.10.11-x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>osx.10.11-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\ReleasePublish\osx.10.11-x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>osx.10.11-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Debug</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\DebugPublish\win-x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\ReleasePublish\win-x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>
</Project>

View File

@ -25,8 +25,6 @@ environment:
secure: 9f78dD9jN5vlVZ0zv15kdD4Mj+/+uacfu29bbGC+cBVFs834aFVf5Ci+n3NP3Bl7
codesignpasswd:
secure: iKv14aGuHUDEfb5fSIBMuSsu1JnisWXL8wJ7x/2DCNtggWKevjhOFBOrI7c95xBY
gh_token:
secure: tAYY5TbyhAGws2MxxoIKdE3B+VlCvnyuzmYbylNnZivghfBYMeC22GqIxDfUUmt8
cache:
- packages
@ -40,12 +38,13 @@ before_build:
build_script:
- ps: msbuild /nologo /v:m /p:Configuration="$env:CONFIGURATION" /p:SquirrelBuildTarget="$env:DEPLOY_SITE_GIT\BililiveRecorder" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /t:Publish /p:PublishProfile=any-$env:CONFIGURATION /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /t:Publish /p:PublishProfile=linux-x64-$env:CONFIGURATION /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /t:Publish /p:PublishProfile=linux-arm-$env:CONFIGURATION /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /t:Publish /p:PublishProfile=linux-arm64-$env:CONFIGURATION /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /t:Publish /p:PublishProfile=win-x64-$env:CONFIGURATION /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /t:Publish /p:PublishProfile=osx_10_11-x64-$env:CONFIGURATION /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="linux-arm" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="linux-arm64" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="linux-x64" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="osx.10.11-x64" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="osx-x64" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="win-x64" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
for:
-
@ -67,20 +66,21 @@ for:
configuration: Debug
artifacts:
- path: BililiveRecorder.WPF\bin\Debug
name: BililiveRecorderDebugBuild
- path: BililiveRecorder.Cli\bin\DebugPublish\any
name: BililiveRecorderCliDebug-AnyCPU
- path: BililiveRecorder.Cli\bin\DebugPublish\win-x64
name: BililiveRecorderCliDebug-win-x64
- path: BililiveRecorder.Cli\bin\DebugPublish\linux-x64
name: BililiveRecorderCliDebug-linux-x64
- path: BililiveRecorder.Cli\bin\DebugPublish\linux-arm
name: BililiveRecorderCliDebug-linux-arm
- path: BililiveRecorder.Cli\bin\DebugPublish\linux-arm64
name: BililiveRecorderCliDebug-linux-arm64
- path: BililiveRecorder.Cli\bin\DebugPublish\osx.10.11-x64
name: BililiveRecorderCliDebug-osx.10.11-x64
name: BililiveRecorderWPFDebugBuild
- path: BililiveRecorder.Cli\publish\any
name: BililiveRecorderCliDebugBuild
- path: BililiveRecorder.Cli\publish\linux-arm
name: BililiveRecorderCliDebugBuild-linux-arm
- path: BililiveRecorder.Cli\publish\linux-arm64
name: BililiveRecorderCliDebugBuild-linux-arm64
- path: BililiveRecorder.Cli\publish\linux-x64
name: BililiveRecorderCliDebugBuild-linux-x64
- path: BililiveRecorder.Cli\publish\osx.10.11-x64
name: BililiveRecorderCliDebugBuild-osx.10.11-x64
- path: BililiveRecorder.Cli\publish\osx-x64
name: BililiveRecorderCliDebugBuild-osx-x64
- path: BililiveRecorder.Cli\publish\win-x64
name: BililiveRecorderCliDebugBuild-win-x64
on_finish:
- cmd: curl -X POST https://api.github.com/repos/NyaMisty/BililiveRecorderDocker/releases -d {\"tag_name\":\"%APPVEYOR_BUILD_VERSION%\"} --user "NyaMisty:%gh_token%"
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))