Skip to content

Commit

Permalink
添加cli工具
Browse files Browse the repository at this point in the history
  • Loading branch information
MonoLogueChi committed Mar 16, 2020
1 parent 8ea5d2c commit bf9de45
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 15 deletions.
19 changes: 19 additions & 0 deletions CommandLine/Danmu.CommandLine.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<PublishTrimmed>true</PublishTrimmed>
<TieredCompilationQuickJit>false</TieredCompilationQuickJit>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.0.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.7.82" />
</ItemGroup>

<ItemGroup>
<TrimmerRootDescriptor Include="TrimmerRoots.xml" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions CommandLine/Danmu.CommandLine.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>D:\MonoLogueChi\Documents\GitHub\Danmu.Server\CommandLine\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>
30 changes: 30 additions & 0 deletions CommandLine/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using CommandLine;
using Danmu.CommandLine.Utils;

namespace Danmu.CommandLine
{
internal class Program
{
private static void Main(string[] args)
{
Parser.Default.ParseArguments<Options>(args)
.WithParsed(RunOptions)
.WithNotParsed(HandleParseError);
}

private static void RunOptions(Options opts)
{
if (opts.Version)
Console.WriteLine((Assembly.GetEntryAssembly() ?? throw new InvalidOperationException())
.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion);
}

private static void HandleParseError(IEnumerable<Error> errs)
{
//handle errors
}
}
}
18 changes: 18 additions & 0 deletions CommandLine/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PublishDir>bin\Release\netcoreapp3.1\publish\</PublishDir>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>True</PublishTrimmed>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?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">
</Project>
3 changes: 3 additions & 0 deletions CommandLine/TrimmerRoots.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<linker>
<assembly fullname="CommandLine" preserve="all"/>
</linker>
11 changes: 11 additions & 0 deletions CommandLine/Utils/Options.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using CommandLine;

namespace Danmu.CommandLine.Utils
{
public class Options
{
[Option('v', "version", Required = false, HelpText = "程序版本")]
public bool Version { get; set; }
}
}
15 changes: 15 additions & 0 deletions Danmu.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,37 @@ VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Danmu", "Danmu\Danmu.csproj", "{B9C588D4-1F1B-47C6-8DFD-8434978890A7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Danmu.CommandLine", "CommandLine\Danmu.CommandLine.csproj", "{2765DE2D-69D1-4F25-9B7C-5DBB2711B6BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Release-Linux32|Any CPU = Release-Linux32|Any CPU
Release-Linux64|Any CPU = Release-Linux64|Any CPU
Release-Win|Any CPU = Release-Win|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B9C588D4-1F1B-47C6-8DFD-8434978890A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9C588D4-1F1B-47C6-8DFD-8434978890A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9C588D4-1F1B-47C6-8DFD-8434978890A7}.Release|Any CPU.ActiveCfg = Release-Linux64|Any CPU
{B9C588D4-1F1B-47C6-8DFD-8434978890A7}.Release|Any CPU.Build.0 = Release-Linux64|Any CPU
{B9C588D4-1F1B-47C6-8DFD-8434978890A7}.Release-Linux32|Any CPU.ActiveCfg = Release-Linux32|Any CPU
{B9C588D4-1F1B-47C6-8DFD-8434978890A7}.Release-Linux32|Any CPU.Build.0 = Release-Linux32|Any CPU
{B9C588D4-1F1B-47C6-8DFD-8434978890A7}.Release-Linux64|Any CPU.ActiveCfg = Release-Linux64|x64
{B9C588D4-1F1B-47C6-8DFD-8434978890A7}.Release-Linux64|Any CPU.Build.0 = Release-Linux64|x64
{B9C588D4-1F1B-47C6-8DFD-8434978890A7}.Release-Win|Any CPU.ActiveCfg = Release-Win|Any CPU
{B9C588D4-1F1B-47C6-8DFD-8434978890A7}.Release-Win|Any CPU.Build.0 = Release-Win|Any CPU
{2765DE2D-69D1-4F25-9B7C-5DBB2711B6BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2765DE2D-69D1-4F25-9B7C-5DBB2711B6BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2765DE2D-69D1-4F25-9B7C-5DBB2711B6BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2765DE2D-69D1-4F25-9B7C-5DBB2711B6BC}.Release|Any CPU.Build.0 = Release|Any CPU
{2765DE2D-69D1-4F25-9B7C-5DBB2711B6BC}.Release-Linux32|Any CPU.ActiveCfg = Release|Any CPU
{2765DE2D-69D1-4F25-9B7C-5DBB2711B6BC}.Release-Linux32|Any CPU.Build.0 = Release|Any CPU
{2765DE2D-69D1-4F25-9B7C-5DBB2711B6BC}.Release-Linux64|Any CPU.ActiveCfg = Release|Any CPU
{2765DE2D-69D1-4F25-9B7C-5DBB2711B6BC}.Release-Linux64|Any CPU.Build.0 = Release|Any CPU
{2765DE2D-69D1-4F25-9B7C-5DBB2711B6BC}.Release-Win|Any CPU.ActiveCfg = Release|Any CPU
{2765DE2D-69D1-4F25-9B7C-5DBB2711B6BC}.Release-Win|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
11 changes: 11 additions & 0 deletions Danmu.sln.DotSettings.user
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@
&lt;Assembly Path="C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.1\System.Private.CoreLib.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Users\MonoLogueChi\.nuget\packages\microsoft.entityframeworkcore\3.1.2\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\3.1.1\Microsoft.Extensions.Identity.Core.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Users\MonoLogueChi\.nuget\packages\commandlineparser\2.7.82\lib\netstandard2.0\CommandLine.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\3.1.1\Microsoft.AspNetCore.Cors.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\3.1.1\Microsoft.AspNetCore.Authorization.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\3.1.1\Microsoft.AspNetCore.Mvc.Core.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.1\System.ComponentModel.Annotations.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\3.1.0\ref\netcoreapp3.1\Microsoft.AspNetCore.Hosting.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\3.1.0\ref\netcoreapp3.1\Microsoft.AspNetCore.Authentication.Cookies.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Users\MonoLogueChi\.nuget\packages\microsoft.extensions.configuration.binder\3.1.2\lib\netcoreapp3.1\Microsoft.Extensions.Configuration.Binder.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\3.1.0\ref\netcoreapp3.1\Microsoft.AspNetCore.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\3.1.0\ref\netcoreapp3.1\Microsoft.AspNetCore.HttpOverrides.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=artplayer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bili/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=bilibili/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Danmu/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Danmus/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dplayer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Npgsql/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Postgre/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=vids/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
4 changes: 3 additions & 1 deletion Danmu/Danmu.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@
<PackageReference Include="VueCliMiddleware" Version="3.1.1" />
</ItemGroup>

<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
<ItemGroup>
<TrimmerRootDescriptor Include="TrimmerRoots.xml" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions Danmu/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release-Linux64</LastUsedBuildConfiguration>
<LastUsedBuildConfiguration>Release-Win</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ProjectGuid>b9c588d4-1f1b-47c6-8dfd-8434978890a7</ProjectGuid>
<SelfContained>true</SelfContained>
<publishUrl>bin\Release-Linux64\netcoreapp3.1\publish\</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<publishUrl>bin\Release-Win\netcoreapp3.1\publish\</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishSingleFile>True</PublishSingleFile>
<PublishTrimmed>False</PublishTrimmed>
<PublishTrimmed>True</PublishTrimmed>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion Danmu/Properties/PublishProfiles/FolderProfile.pubxml.user
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TimeStampOfAssociatedLegacyPublishXmlFile />
<_PublishTargetUrl>D:\MonoLogueChi\Documents\GitHub\Danmu.Server\Danmu\bin\Release-Linux64\netcoreapp3.1\publish\</_PublishTargetUrl>
<_PublishTargetUrl>D:\MonoLogueChi\Documents\GitHub\Danmu.Server\Danmu\bin\Release-Win\netcoreapp3.1\publish\</_PublishTargetUrl>
</PropertyGroup>
</Project>
17 changes: 17 additions & 0 deletions Danmu/TrimmerRoots.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<linker>
<assembly fullname="Microsoft.AspNetCore" preserve="all"/>
<assembly fullname="Microsoft.AspNetCore.Cors" preserve="all"/>
<assembly fullname="Microsoft.AspNetCore.Authorization" preserve="all"/>
<assembly fullname="Microsoft.AspNetCore.Authentication.Cookies" preserve="all"/>
<assembly fullname="Microsoft.AspNetCore.Mvc.Core" preserve="all"/>
<assembly fullname="Microsoft.AspNetCore.Hosting" preserve="all"/>
<assembly fullname="Microsoft.AspNetCore.HttpOverrides" preserve="all"/>

<assembly fullname="Microsoft.EntityFrameworkCore" preserve="all"/>
<assembly fullname="Npgsql.EntityFrameworkCore.PostgreSQL" preserve="all"/>

<assembly fullname="Microsoft.Extensions.Identity.Core" preserve="all"/>
<assembly fullname="Microsoft.Extensions.Configuration.Binder" preserve="all"/>

<assembly fullname="System.ComponentModel.Annotations" preserve="all"/>
</linker>
34 changes: 26 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ steps:
inputs:
script: |
sed -i 's/<PublishReadyToRun>false/<PublishReadyToRun>true/g' $(Build.SourcesDirectory)/Danmu/Danmu.csproj
sed -i 's/<Version>1.0.0</Version>/<Version>$(Build.BuildNumber)</Version>/g' $(Build.SourcesDirectory)/CommandLine/Danmu.CommandLine.csproj
- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: "-c Release-Linux64 -r linux-x64 --self-contained false --output $(Build.ArtifactStagingDirectory)/Danmu64-R2R"
arguments: "Danmu -c Release-Linux64 -r linux-x64 --self-contained false --output $(Build.ArtifactStagingDirectory)/Danmu64-R2R"
zipAfterPublish: False

##开启程序集链接
Expand All @@ -53,7 +54,7 @@ steps:
inputs:
command: publish
publishWebProjects: True
arguments: "-c Release-Linux64 -r linux-x64 --self-contained true -p:PublishSingleFile=true --output $(Build.ArtifactStagingDirectory)/Danmu64-R2R-SCD"
arguments: "Danmu -c Release-Linux64 -r linux-x64 --self-contained true -p:PublishSingleFile=true --output $(Build.ArtifactStagingDirectory)/Danmu64-R2R-SCD"
zipAfterPublish: False

- task: ArchiveFiles@2
Expand Down Expand Up @@ -86,21 +87,21 @@ steps:
inputs:
command: publish
publishWebProjects: True
arguments: "-c Release-Linux64 -r linux-x64 --self-contained true -p:PublishSingleFile=true --output $(Build.ArtifactStagingDirectory)/Danmu64-SCD"
arguments: "Danmu -c Release-Linux64 -r linux-x64 --self-contained true -p:PublishSingleFile=true --output $(Build.ArtifactStagingDirectory)/Danmu64-SCD"
zipAfterPublish: False

- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: "-c Release-Linux32 -r linux-arm --self-contained true -p:PublishSingleFile=true --output $(Build.ArtifactStagingDirectory)/Danmu32-Arm-SCD"
arguments: "Danmu -c Release-Linux32 -r linux-arm --self-contained true -p:PublishSingleFile=true --output $(Build.ArtifactStagingDirectory)/Danmu32-Arm-SCD"
zipAfterPublish: False

- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: "-c Release-Win -r win-x64 --self-contained true -p:PublishSingleFile=true --output $(Build.ArtifactStagingDirectory)/Danmu64-Win-SCD"
arguments: "Danmu -c Release-Win -r win-x64 --self-contained true -p:PublishSingleFile=true --output $(Build.ArtifactStagingDirectory)/Danmu64-Win-SCD"
zipAfterPublish: False


Expand All @@ -115,21 +116,21 @@ steps:
inputs:
command: publish
publishWebProjects: True
arguments: "-c Release-Linux64 -r linux-x64 --self-contained false --output $(Build.ArtifactStagingDirectory)/Danmu64"
arguments: "Danmu -c Release-Linux64 -r linux-x64 --self-contained false --output $(Build.ArtifactStagingDirectory)/Danmu64"
zipAfterPublish: False

- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: "-c Release-Linux32 -r linux-arm --self-contained false --output $(Build.ArtifactStagingDirectory)/Danmu32-Arm"
arguments: "Danmu -c Release-Linux32 -r linux-arm --self-contained false --output $(Build.ArtifactStagingDirectory)/Danmu32-Arm"
zipAfterPublish: False

- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: "-c Release-Win -r win-x64 --self-contained false --output $(Build.ArtifactStagingDirectory)/Danmu64-Win"
arguments: "Danmu -c Release-Win -r win-x64 --self-contained false --output $(Build.ArtifactStagingDirectory)/Danmu64-Win"
zipAfterPublish: False


Expand Down Expand Up @@ -188,6 +189,23 @@ steps:
archiveFile: "$(Build.ArtifactStagingDirectory)/win64.scd.tar.xz"
replaceExistingArchive: true

## CLI工具
- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: "CommandLine -c Release-Linux64 -r linux-x64 --self-contained true -p:PublishSingleFile=true --output $(Build.ArtifactStagingDirectory)/Cli-Tool"
zipAfterPublish: False

- task: ArchiveFiles@2
inputs:
rootFolderOrFile: "$(Build.ArtifactStagingDirectory)/Cli-Tool/CommandLine"
includeRootFolder: true
archiveType: "tar"
tarCompression: "xz"
archiveFile: "$(Build.ArtifactStagingDirectory)/cli.tar.xz"
replaceExistingArchive: true

## 提交
- task: GithubRelease@0
displayName: "Edit GitHub Release"
Expand Down

0 comments on commit bf9de45

Please sign in to comment.