From 7425ef9225224f643e09924937800beb440f062c Mon Sep 17 00:00:00 2001 From: Vitaliya Chumakova Date: Mon, 16 Aug 2021 22:30:39 +0300 Subject: [PATCH] Rewrite the project system --- .github/workflows/dotnet.yml | 27 +++++++++++------ Directory.Build.props | 17 +++++++++++ Directory.Packages.props | 7 +++++ FriendAccepter/AssemblyInfo.cs | 3 ++ FriendAccepter/Directory.Build.props | 12 ++++++++ FriendAccepter/FriendAccepter.cs | 22 -------------- FriendAccepter/FriendAccepter.csproj | 19 ++++++------ FriendAccepter/FriendAccepterPlugin.cs | 40 ++++++++++++++++++++++++++ 8 files changed, 106 insertions(+), 41 deletions(-) create mode 100644 Directory.Build.props create mode 100644 Directory.Packages.props create mode 100644 FriendAccepter/AssemblyInfo.cs create mode 100644 FriendAccepter/Directory.Build.props delete mode 100644 FriendAccepter/FriendAccepter.cs create mode 100644 FriendAccepter/FriendAccepterPlugin.cs diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 65fbfc0..a0a08cc 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,10 +1,6 @@ name: .NET -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] +on: [ push, pull_request ] env: DOTNET_SDK_VERSION: 5.0.x @@ -30,11 +26,19 @@ jobs: - name: Build with .NET Framework run: dotnet publish -c Release -f net48 -o out/generic-netf + - name: Archive generic-netf release + uses: thedoctor0/zip-release@master + with: + directory: out/generic + type: 'zip' + filename: 'out/generic.zip' + exclusions: '*.json' + - name: Upload generic-netf artifacts uses: actions/upload-artifact@v2 with: name: ${{ github.event.repository.name }}-generic-netf - path: out/generic-netf + path: out/generic-netf.zip build-generic: runs-on: windows-latest @@ -56,11 +60,19 @@ jobs: - name: Build with .NET Core run: dotnet publish -c Release -f net5.0 -o out/generic + - name: Archive generic release + uses: thedoctor0/zip-release@master + with: + directory: out/generic + type: 'zip' + filename: 'out/generic.zip' + exclusions: '*.json' + - name: Upload generic artifacts uses: actions/upload-artifact@v2 with: name: ${{ github.event.repository.name }}-generic - path: out/generic + path: out/generic.zip release: if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} @@ -88,7 +100,6 @@ jobs: with: tag_name: ${{ github.ref }} release_name: ${{ github.event.repository.name }} V${{ github.ref }} - prerelease: true - name: Upload generic artifacts to GitHub release uses: actions/upload-release-asset@v1.0.2 diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..70dae28 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,17 @@ + + + + + Vital7 + $(Authors) + Copyright © $(Company) 2020-$([System.DateTime]::UtcNow.Year) + + https://github.com/$(Company)/$(MSBuildProjectName) + $(PackageProjectUrl)/releases + false + Library + $(PackageProjectUrl).git + false + + + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..82c00fb --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/FriendAccepter/AssemblyInfo.cs b/FriendAccepter/AssemblyInfo.cs new file mode 100644 index 0000000..0270020 --- /dev/null +++ b/FriendAccepter/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System; + +[assembly: CLSCompliant(true)] diff --git a/FriendAccepter/Directory.Build.props b/FriendAccepter/Directory.Build.props new file mode 100644 index 0000000..3354c1d --- /dev/null +++ b/FriendAccepter/Directory.Build.props @@ -0,0 +1,12 @@ + + + + + + Simple ASF plugin for accepting all friend invites. + 2.0.0.0 + + + + + diff --git a/FriendAccepter/FriendAccepter.cs b/FriendAccepter/FriendAccepter.cs deleted file mode 100644 index 62d2989..0000000 --- a/FriendAccepter/FriendAccepter.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Composition; -using System.Reflection; -using System.Threading.Tasks; -using ArchiSteamFarm.Core; -using ArchiSteamFarm.Plugins.Interfaces; -using ArchiSteamFarm.Steam; -using JetBrains.Annotations; - -namespace FriendAccepter { - [Export(typeof(IPlugin))] - [UsedImplicitly] - public class FriendAccepter : IBotFriendRequest { - public void OnLoaded() { - ASF.ArchiLogger.LogGenericInfo(Name + " by Vital7 | Support & source code: https://github.com/Vital7/FriendAccepter"); - } - - public string Name => nameof(FriendAccepter); - public Version Version => Assembly.GetExecutingAssembly().GetName().Version ?? throw new InvalidOperationException(nameof(Version)); - public Task OnBotFriendRequest(Bot bot, ulong steamID) => Task.FromResult(true); - } -} diff --git a/FriendAccepter/FriendAccepter.csproj b/FriendAccepter/FriendAccepter.csproj index 447b717..aee1f85 100644 --- a/FriendAccepter/FriendAccepter.csproj +++ b/FriendAccepter/FriendAccepter.csproj @@ -1,16 +1,13 @@  - - enable - net5.0;net48 - latest - 1.1.1.0 - - - - - + + + + + + + - + diff --git a/FriendAccepter/FriendAccepterPlugin.cs b/FriendAccepter/FriendAccepterPlugin.cs new file mode 100644 index 0000000..5338621 --- /dev/null +++ b/FriendAccepter/FriendAccepterPlugin.cs @@ -0,0 +1,40 @@ +using System; +using System.Composition; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using ArchiSteamFarm.Core; +using ArchiSteamFarm.Plugins.Interfaces; +using ArchiSteamFarm.Steam; +using JetBrains.Annotations; + +namespace FriendAccepter { + [Export(typeof(IPlugin))] + [UsedImplicitly] + public class FriendAccepterPlugin : IBotFriendRequest { + public void OnLoaded() { + Assembly assembly = Assembly.GetExecutingAssembly(); + string repository = assembly + .GetCustomAttributes() + .First(x => x.Key == "RepositoryUrl") + .Value ?? throw new InvalidOperationException(nameof(AssemblyMetadataAttribute)); + + const string git = ".git"; + int index = repository.IndexOf(git, StringComparison.Ordinal); + if (index >= 0) { + repository = repository[..(index + 1)]; + } + + string company = assembly + .GetCustomAttribute()?.Company ?? throw new InvalidOperationException(nameof(AssemblyCompanyAttribute)); + + ASF.ArchiLogger.LogGenericInfo(Name + " by " + company + " | Support & source code: " + repository); + } + + public string Name => nameof(FriendAccepter); + public Version Version => Assembly.GetExecutingAssembly().GetName().Version ?? throw new InvalidOperationException(nameof(Version)); + + [CLSCompliant(false)] + public Task OnBotFriendRequest(Bot bot, ulong steamID) => Task.FromResult(true); + } +}