diff --git a/.travis.yml b/.travis.yml index 08d11ec9b..50e2b175b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ git: group: travis_latest # ASF is based on .NET Core platform, we're not building with Mono -dotnet: 2.2 +dotnet: 3.0 mono: none env: @@ -18,7 +18,7 @@ env: - CONFIGURATION: Release - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 - - NET_CORE_VERSION: netcoreapp2.2 + - NET_CORE_VERSION: netcoreapp3.0 - VARIANTS="generic linux-arm linux-x64 osx-x64 win-x64" # NOTE: When modifying variants, don't forget to update ASF_VARIANT definitions in SharedInfo.cs! before_script: - | @@ -48,21 +48,21 @@ script: set -eu # We no longer need +eu on OSX fi - dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/source' /nologo - dotnet build ArchiSteamFarm.CustomPlugins.ExamplePlugin -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/source' /nologo - dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/source' /nologo + dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" /nologo + dotnet build ArchiSteamFarm.CustomPlugins.ExamplePlugin -c "$CONFIGURATION" -f "$NET_CORE_VERSION" /nologo + dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" /nologo publish() { if [ "$1" = 'generic' ]; then # TODO: Workaround https://github.com/mono/linker/issues/286 (don't forget to remove it from docker files too) - dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/${1}" --no-restore /nologo "/p:ASFVariant=$1" "/p:LinkDuringPublish=false" + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/${1}" --no-restore /nologo "/p:ASFVariant=$1" "/p:PublishTrimmed=false" "/p:UseAppHost=false" else dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/${1}" -r "$1" --no-restore /nologo "/p:ASFVariant=$1" fi # If we include any overlay for this variant, copy it to output directory if [ -d "ArchiSteamFarm/overlay/${1}" ]; then - cp "ArchiSteamFarm/overlay/${1}/"* "ArchiSteamFarm/out/${1}" + cp "ArchiSteamFarm/overlay/${1}/"* "out/${1}" fi } @@ -75,15 +75,18 @@ script: wait set +u # This is needed to continue Travis build matrix: + # TODO: Remove failure allow once linux works with 3.0 + allow_failures: + - os: linux # We can use fast finish, as we don't need to wait for allow_failures builds to mark build as success fast_finish: true include: # We're building ASF with dotnet on latest versions of Linux and OS X # Sadly, travis is still missing support for selecting latest images: https://github.com/travis-ci/travis-ci/issues/8922 - os: linux - # Ref: https://docs.travis-ci.com/user/reference/xenial - dist: xenial + # Ref: https://docs.travis-ci.com/user/reference/bionic + dist: bionic - os: osx # Ref: https://docs.travis-ci.com/user/reference/osx - dotnet: 2.2.402 # For OSX, we need absolute dotnet version until https://github.com/dotnet/core-setup/issues/4187 is resolved + dotnet: 3.0.100 # For OSX, we need absolute dotnet version until https://github.com/dotnet/core-setup/issues/4187 is resolved osx_image: xcode11 diff --git a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ArchiSteamFarm.CustomPlugins.ExamplePlugin.csproj b/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ArchiSteamFarm.CustomPlugins.ExamplePlugin.csproj index 6c5808963..a3c09fb46 100644 --- a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ArchiSteamFarm.CustomPlugins.ExamplePlugin.csproj +++ b/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ArchiSteamFarm.CustomPlugins.ExamplePlugin.csproj @@ -18,11 +18,11 @@ - netcoreapp2.2;net48 + netcoreapp3.0;net48 - netcoreapp2.2 + netcoreapp3.0 diff --git a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/CatAPI.cs b/ArchiSteamFarm.CustomPlugins.ExamplePlugin/CatAPI.cs index 1114886ea..64d74d3c5 100644 --- a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/CatAPI.cs +++ b/ArchiSteamFarm.CustomPlugins.ExamplePlugin/CatAPI.cs @@ -20,7 +20,6 @@ // limitations under the License. using System; -using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using JetBrains.Annotations; using Newtonsoft.Json; @@ -51,7 +50,7 @@ namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin { return Uri.EscapeUriString(response.Content.Link); } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] private sealed class MeowResponse { #pragma warning disable 649 [JsonProperty(PropertyName = "file", Required = Required.Always)] diff --git a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/nuget.config b/ArchiSteamFarm.CustomPlugins.ExamplePlugin/nuget.config deleted file mode 100644 index f5534b3e0..000000000 --- a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/nuget.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/ArchiSteamFarm.Tests/ArchiSteamFarm.Tests.csproj b/ArchiSteamFarm.Tests/ArchiSteamFarm.Tests.csproj index e175e5b4b..833fe6f98 100644 --- a/ArchiSteamFarm.Tests/ArchiSteamFarm.Tests.csproj +++ b/ArchiSteamFarm.Tests/ArchiSteamFarm.Tests.csproj @@ -19,11 +19,11 @@ - netcoreapp2.2;net48 + netcoreapp3.0;net48 - netcoreapp2.2 + netcoreapp3.0 diff --git a/ArchiSteamFarm.Tests/nuget.config b/ArchiSteamFarm.Tests/nuget.config deleted file mode 100644 index f5534b3e0..000000000 --- a/ArchiSteamFarm.Tests/nuget.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/ArchiSteamFarm/Actions.cs b/ArchiSteamFarm/Actions.cs index 7fce3948d..eeff5cae0 100644 --- a/ArchiSteamFarm/Actions.cs +++ b/ArchiSteamFarm/Actions.cs @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -233,7 +232,7 @@ namespace ArchiSteamFarm { } [PublicAPI] - [SuppressMessage("ReSharper", "FunctionComplexityOverflow")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] public async Task<(bool Success, string Message)> SendTradeOffer(uint appID = Steam.Asset.SteamAppID, ulong contextID = Steam.Asset.SteamCommunityContextID, ulong targetSteamID = 0, string tradeToken = null, IReadOnlyCollection wantedRealAppIDs = null, IReadOnlyCollection wantedTypes = null) { if ((appID == 0) || (contextID == 0)) { Bot.ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(contextID)); diff --git a/ArchiSteamFarm/ArchiHandler.cs b/ArchiSteamFarm/ArchiHandler.cs index 60a4257f1..30efb8608 100644 --- a/ArchiSteamFarm/ArchiHandler.cs +++ b/ArchiSteamFarm/ArchiHandler.cs @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Net; @@ -706,7 +705,7 @@ namespace ArchiSteamFarm { Client.PostCallback(new VanityURLChangedCallback(packetMsg.TargetJobID, response.Body)); } - [SuppressMessage("ReSharper", "MemberCanBeInternal")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "MemberCanBeInternal")] public sealed class PurchaseResponseCallback : CallbackMsg { public readonly Dictionary Items; diff --git a/ArchiSteamFarm/ArchiSteamFarm.csproj b/ArchiSteamFarm/ArchiSteamFarm.csproj index 0ba511e7f..d44de6a75 100644 --- a/ArchiSteamFarm/ArchiSteamFarm.csproj +++ b/ArchiSteamFarm/ArchiSteamFarm.csproj @@ -2,16 +2,15 @@ ASF.ico - 4.0.4.4 + 4.1.0.0 JustArchi JustArchi true - false Copyright © ArchiSteamFarm 2015-2019 $(DefaultItemExcludes);config/**;debug/**;out/**;overlay/** ASF is an application that allows you to farm steam cards using multiple steam accounts simultaneously. none - 4.0.4.4 + 4.1.0.0 true latest 1591 @@ -19,6 +18,7 @@ https://github.com/JustArchiNET/ArchiSteamFarm/raw/master/resources/ASF.ico http://www.apache.org/licenses/LICENSE-2.0 https://github.com/JustArchiNET/ArchiSteamFarm + false Git https://github.com/JustArchiNET/ArchiSteamFarm.git linux-arm;linux-x64;osx-x64;win-x64 @@ -27,11 +27,11 @@ - netcoreapp2.2;net48 + netcoreapp3.0;net48 - netcoreapp2.2 + netcoreapp3.0 @@ -45,16 +45,6 @@ $(DefineConstants);ASF_VARIANT_$(ASFVariant.Replace('-', '_').ToUpperInvariant()) - - - - - - - - - - all @@ -64,16 +54,6 @@ - - - - - - - - - - @@ -88,12 +68,21 @@ - - + + + + + + + + + + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Net.Http.dll diff --git a/ArchiSteamFarm/ArchiWebHandler.cs b/ArchiSteamFarm/ArchiWebHandler.cs index 43ea16639..0ef92b4a8 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -22,7 +22,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Net; using System.Net.Http; @@ -123,7 +122,7 @@ namespace ArchiSteamFarm { [ItemCanBeNull] [PublicAPI] - [SuppressMessage("ReSharper", "FunctionComplexityOverflow")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] public async Task> GetInventory(ulong steamID = 0, uint appID = Steam.Asset.SteamAppID, ulong contextID = Steam.Asset.SteamCommunityContextID, bool? marketable = null, bool? tradable = null, IReadOnlyCollection wantedRealAppIDs = null, IReadOnlyCollection wantedTypes = null, IReadOnlyCollection<(uint RealAppID, Steam.Asset.EType Type, Steam.Asset.ERarity Rarity)> wantedSets = null) { if ((appID == 0) || (contextID == 0)) { Bot.ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(contextID)); diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index ea4d40ba9..bdf41c783 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -24,7 +24,6 @@ using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Specialized; -using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Security.Cryptography; @@ -2775,7 +2774,7 @@ namespace ArchiSteamFarm { WalletCurrency = callback.Currency; } - [SuppressMessage("ReSharper", "FunctionComplexityOverflow")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] private async Task RedeemGamesInBackground() { if (!await GamesRedeemerInBackgroundSemaphore.WaitAsync(0).ConfigureAwait(false)) { return; diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index 15137adb8..afa1c4dd8 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -22,7 +22,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Threading; @@ -35,7 +34,7 @@ using Newtonsoft.Json.Linq; using SteamKit2; namespace ArchiSteamFarm { - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] public sealed class BotConfig { internal const byte SteamParentalCodeLength = 4; diff --git a/ArchiSteamFarm/Collections/ConcurrentHashSet.cs b/ArchiSteamFarm/Collections/ConcurrentHashSet.cs index f7f97ce52..3a0ba229f 100644 --- a/ArchiSteamFarm/Collections/ConcurrentHashSet.cs +++ b/ArchiSteamFarm/Collections/ConcurrentHashSet.cs @@ -23,7 +23,6 @@ using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; using JetBrains.Annotations; @@ -47,7 +46,7 @@ namespace ArchiSteamFarm.Collections { public bool Add(T item) => BackingCollection.TryAdd(item, true); public void Clear() => BackingCollection.Clear(); - [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] public bool Contains(T item) => BackingCollection.ContainsKey(item); public void CopyTo(T[] array, int arrayIndex) => BackingCollection.Keys.CopyTo(array, arrayIndex); @@ -98,7 +97,7 @@ namespace ArchiSteamFarm.Collections { return otherSet.Any(Contains); } - [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] public bool Remove(T item) => BackingCollection.TryRemove(item, out _); public bool SetEquals(IEnumerable other) { @@ -127,8 +126,8 @@ namespace ArchiSteamFarm.Collections { } } - [SuppressMessage("ReSharper", "AnnotationConflictInHierarchy")] - [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AnnotationConflictInHierarchy")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] void ICollection.Add([NotNull] T item) => Add(item); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); diff --git a/ArchiSteamFarm/Collections/ConcurrentList.cs b/ArchiSteamFarm/Collections/ConcurrentList.cs index 5960b8050..f0f514a4d 100644 --- a/ArchiSteamFarm/Collections/ConcurrentList.cs +++ b/ArchiSteamFarm/Collections/ConcurrentList.cs @@ -21,7 +21,6 @@ using System.Collections; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using JetBrains.Annotations; using Nito.AsyncEx; @@ -82,7 +81,7 @@ namespace ArchiSteamFarm.Collections { } [NotNull] - [SuppressMessage("ReSharper", "AnnotationRedundancyInHierarchy")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AnnotationRedundancyInHierarchy")] public IEnumerator GetEnumerator() => new ConcurrentEnumerator(BackingCollection, Lock.ReaderLock()); public int IndexOf(T item) { @@ -110,7 +109,7 @@ namespace ArchiSteamFarm.Collections { } [NotNull] - [SuppressMessage("ReSharper", "AnnotationRedundancyInHierarchy")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "AnnotationRedundancyInHierarchy")] IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); internal void ReplaceWith([NotNull] IEnumerable collection) { diff --git a/ArchiSteamFarm/Commands.cs b/ArchiSteamFarm/Commands.cs index a7d4a8ed8..03180eee1 100644 --- a/ArchiSteamFarm/Commands.cs +++ b/ArchiSteamFarm/Commands.cs @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; using System.Text.RegularExpressions; @@ -1623,7 +1622,7 @@ namespace ArchiSteamFarm { return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; } - [SuppressMessage("ReSharper", "FunctionComplexityOverflow")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] private async Task<(string Response, Dictionary OwnedGames)> ResponseOwns(ulong steamID, string query) { if ((steamID == 0) || string.IsNullOrEmpty(query)) { Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(query)); @@ -2142,7 +2141,7 @@ namespace ArchiSteamFarm { return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null; } - [SuppressMessage("ReSharper", "FunctionComplexityOverflow")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] private async Task ResponseRedeem(ulong steamID, string keysText, ERedeemFlags redeemFlags = ERedeemFlags.None) { if ((steamID == 0) || string.IsNullOrEmpty(keysText)) { Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(keysText)); diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs index d5f811e83..5760758c4 100644 --- a/ArchiSteamFarm/GlobalConfig.cs +++ b/ArchiSteamFarm/GlobalConfig.cs @@ -22,7 +22,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; using System.IO; using System.Net; using System.Threading; @@ -34,7 +33,7 @@ using Newtonsoft.Json.Linq; using SteamKit2; namespace ArchiSteamFarm { - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] public sealed class GlobalConfig { internal const byte DefaultConnectionTimeout = 90; internal const byte DefaultLoginLimiterDelay = 10; diff --git a/ArchiSteamFarm/IPC/ArchiKestrel.cs b/ArchiSteamFarm/IPC/ArchiKestrel.cs index 8cf637393..9b09377f0 100644 --- a/ArchiSteamFarm/IPC/ArchiKestrel.cs +++ b/ArchiSteamFarm/IPC/ArchiKestrel.cs @@ -30,12 +30,20 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using NLog.Web; +#if !NETFRAMEWORK +using Microsoft.Extensions.Hosting; +#endif + namespace ArchiSteamFarm.IPC { internal static class ArchiKestrel { internal static HistoryTarget HistoryTarget { get; private set; } internal static string WebsiteDirectory { get; private set; } = Path.Combine(SharedInfo.HomeDirectory, SharedInfo.WebsiteDirectory); +#if NETFRAMEWORK private static IWebHost KestrelWebHost; +#else + private static IHost KestrelWebHost; +#endif internal static void OnNewHistoryTarget(HistoryTarget historyTarget = null) { if (HistoryTarget != null) { @@ -57,7 +65,11 @@ namespace ArchiSteamFarm.IPC { ASF.ArchiLogger.LogGenericInfo(Strings.IPCStarting); // The order of dependency injection matters, pay attention to it - IWebHostBuilder builder = new WebHostBuilder(); +#if NETFRAMEWORK + WebHostBuilder builder = new WebHostBuilder(); +#else + HostBuilder builder = new HostBuilder(); +#endif string customDirectory = Path.Combine(Directory.GetCurrentDirectory(), SharedInfo.WebsiteDirectory); @@ -65,40 +77,55 @@ namespace ArchiSteamFarm.IPC { WebsiteDirectory = customDirectory; } - // Set default directories + // Set default content root builder.UseContentRoot(SharedInfo.HomeDirectory); - builder.UseWebRoot(WebsiteDirectory); - - // Check if custom config is available - string absoluteConfigDirectory = Path.Combine(Directory.GetCurrentDirectory(), SharedInfo.ConfigDirectory); // Firstly initialize settings that user is free to override builder.ConfigureLogging(logging => logging.SetMinimumLevel(Debugging.IsUserDebugging ? LogLevel.Trace : LogLevel.Warning)); - // Now conditionally initialize settings that are not possible to override - if (File.Exists(Path.Combine(absoluteConfigDirectory, SharedInfo.IPCConfigFile))) { - // Set up custom config to be used - builder.UseConfiguration(new ConfigurationBuilder().SetBasePath(absoluteConfigDirectory).AddJsonFile(SharedInfo.IPCConfigFile, false, true).Build()); + // Check if custom config is available + string absoluteConfigDirectory = Path.Combine(Directory.GetCurrentDirectory(), SharedInfo.ConfigDirectory); + bool customConfigExists = File.Exists(Path.Combine(absoluteConfigDirectory, SharedInfo.IPCConfigFile)); - // Use custom config for Kestrel and Logging configuration - builder.UseKestrel((builderContext, options) => options.Configure(builderContext.Configuration.GetSection("Kestrel"))); + if (customConfigExists) { + // Use custom config for logging configuration builder.ConfigureLogging((hostingContext, logging) => logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"))); - } else { - // Use ASF defaults for Kestrel - builder.UseKestrel(options => options.ListenLocalhost(1242)); } // Enable NLog integration for logging builder.UseNLog(); - // Specify Startup class for IPC - builder.UseStartup(); + builder.ConfigureWebHostDefaults( + webBuilder => { + // Set default web root + webBuilder.UseWebRoot(WebsiteDirectory); + + // Now conditionally initialize settings that are not possible to override + if (customConfigExists) { + // Set up custom config to be used + webBuilder.UseConfiguration(new ConfigurationBuilder().SetBasePath(absoluteConfigDirectory).AddJsonFile(SharedInfo.IPCConfigFile, false, true).Build()); + + // Use custom config for Kestrel configuration + webBuilder.UseKestrel((builderContext, options) => options.Configure(builderContext.Configuration.GetSection("Kestrel"))); + } else { + // Use ASF defaults for Kestrel + webBuilder.UseKestrel(options => options.ListenLocalhost(1242)); + } + + // Specify Startup class for IPC + webBuilder.UseStartup(); + } + ); // Init history logger for /Api/Log usage Logging.InitHistoryLogger(); // Start the server +#if NETFRAMEWORK IWebHost kestrelWebHost = null; +#else + IHost kestrelWebHost = null; +#endif try { kestrelWebHost = builder.Build(); diff --git a/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs b/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs index 2d184e815..cbd630a1f 100644 --- a/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs +++ b/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs @@ -21,7 +21,6 @@ using System; using System.Collections.Concurrent; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Net; using System.Threading; @@ -31,7 +30,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; namespace ArchiSteamFarm.IPC.Integration { - [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] internal sealed class ApiAuthenticationMiddleware { internal const string HeadersField = "Authentication"; diff --git a/ArchiSteamFarm/IPC/Requests/CommandRequest.cs b/ArchiSteamFarm/IPC/Requests/CommandRequest.cs index ee59fcf19..1a255905e 100644 --- a/ArchiSteamFarm/IPC/Requests/CommandRequest.cs +++ b/ArchiSteamFarm/IPC/Requests/CommandRequest.cs @@ -21,12 +21,11 @@ using System; using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; using JetBrains.Annotations; using Newtonsoft.Json; namespace ArchiSteamFarm.IPC.Requests { - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] public sealed class CommandRequest { /// /// Specifies the command that will be executed by ASF. diff --git a/ArchiSteamFarm/IPC/Startup.cs b/ArchiSteamFarm/IPC/Startup.cs index 78879aae8..f54a460e4 100644 --- a/ArchiSteamFarm/IPC/Startup.cs +++ b/ArchiSteamFarm/IPC/Startup.cs @@ -43,16 +43,24 @@ namespace ArchiSteamFarm.IPC { public Startup([NotNull] IConfiguration configuration) => Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); +#if NETFRAMEWORK public void Configure(IApplicationBuilder app, IHostingEnvironment env) { +#else + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { +#endif if ((app == null) || (env == null)) { ASF.ArchiLogger.LogNullError(nameof(app) + " || " + nameof(env)); return; } + if (Debugging.IsUserDebugging) { + app.UseDeveloperExceptionPage(); + } + // The order of dependency injection matters, pay attention to it - // Add workaround for missing PathBase feature, https://github.com/aspnet/Hosting/issues/1120 + // TODO: Try to get rid of this workaround for missing PathBase feature, https://github.com/aspnet/AspNetCore/issues/5898 PathString pathBase = Configuration.GetSection("Kestrel").GetValue("PathBase"); if (!string.IsNullOrEmpty(pathBase) && (pathBase != "/")) { @@ -65,6 +73,18 @@ namespace ArchiSteamFarm.IPC { // Add support for response compression app.UseResponseCompression(); + // We need static files support for IPC GUI + app.UseDefaultFiles(); + app.UseStaticFiles(); + + // We need WebSockets support for /Api/Log + app.UseWebSockets(); + +#if !NETFRAMEWORK + // Add support for routing + app.UseRouting(); +#endif + if (!string.IsNullOrEmpty(ASF.GlobalConfig.IPCPassword)) { // We need ApiAuthenticationMiddleware for IPCPassword app.UseWhen(context => context.Request.Path.StartsWithSegments("/Api", StringComparison.OrdinalIgnoreCase), appBuilder => appBuilder.UseMiddleware()); @@ -74,24 +94,21 @@ namespace ArchiSteamFarm.IPC { app.UseCors(); } - // We need WebSockets support for /Api/Log - app.UseWebSockets(); - - // We need MVC for /Api + // Add support for mapping controllers +#if NETFRAMEWORK app.UseMvcWithDefaultRoute(); +#else + app.UseEndpoints(endpoints => endpoints.MapControllers()); +#endif // Use swagger for automatic API documentation generation app.UseSwagger(); // Use friendly swagger UI - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/" + SharedInfo.ASF + "/swagger.json", SharedInfo.ASF + " API")); + app.UseSwaggerUI(options => options.SwaggerEndpoint("/swagger/" + SharedInfo.ASF + "/swagger.json", SharedInfo.ASF + " API")); // We're using index for URL routing in our static files so re-execute all non-API calls on / app.UseWhen(context => !context.Request.Path.StartsWithSegments("/Api", StringComparison.OrdinalIgnoreCase), appBuilder => appBuilder.UseStatusCodePagesWithReExecute("/")); - - // We need static files support for IPC GUI - app.UseDefaultFiles(); - app.UseStaticFiles(); } public void ConfigureServices(IServiceCollection services) { @@ -110,12 +127,12 @@ namespace ArchiSteamFarm.IPC { services.AddResponseCompression(); // Add CORS to allow userscripts and third-party apps - services.AddCors(builder => builder.AddDefaultPolicy(policyBuilder => policyBuilder.AllowAnyOrigin())); + services.AddCors(options => options.AddDefaultPolicy(policyBuilder => policyBuilder.AllowAnyOrigin())); // Add swagger documentation generation services.AddSwaggerGen( - c => { - c.AddSecurityDefinition( + options => { + options.AddSecurityDefinition( nameof(GlobalConfig.IPCPassword), new OpenApiSecurityScheme { Description = nameof(GlobalConfig.IPCPassword) + " authentication using request headers. Check " + SharedInfo.ProjectURL + "/wiki/IPC#authentication for more info.", In = ParameterLocation.Header, @@ -124,7 +141,7 @@ namespace ArchiSteamFarm.IPC { } ); - c.AddSecurityRequirement( + options.AddSecurityRequirement( new OpenApiSecurityRequirement { { new OpenApiSecurityScheme { @@ -139,9 +156,9 @@ namespace ArchiSteamFarm.IPC { } ); - c.EnableAnnotations(); + options.EnableAnnotations(); - c.SwaggerDoc( + options.SwaggerDoc( SharedInfo.ASF, new OpenApiInfo { Contact = new OpenApiContact { Name = SharedInfo.GithubRepo, @@ -160,13 +177,17 @@ namespace ArchiSteamFarm.IPC { string xmlDocumentationFile = Path.Combine(AppContext.BaseDirectory, SharedInfo.AssemblyDocumentation); if (File.Exists(xmlDocumentationFile)) { - c.IncludeXmlComments(xmlDocumentationFile); + options.IncludeXmlComments(xmlDocumentationFile); } } ); // We need MVC for /Api, but we're going to use only a small subset of all available features +#if NETFRAMEWORK IMvcCoreBuilder mvc = services.AddMvcCore(); +#else + IMvcBuilder mvc = services.AddControllers(); +#endif // Add support for controllers declared in custom plugins HashSet assemblies = PluginsCore.LoadAssemblies(); @@ -177,21 +198,26 @@ namespace ArchiSteamFarm.IPC { } } - // Add API explorer for swagger - mvc.AddApiExplorer(); - // Use latest compatibility version for MVC mvc.SetCompatibilityVersion(CompatibilityVersion.Latest); - // Add standard formatters that can be used for serializing/deserializing requests/responses, they're already available in the core +#if NETFRAMEWORK + // Add standard formatters mvc.AddFormatterMappings(); + // Add API explorer for swagger + mvc.AddApiExplorer(); +#endif + // Add JSON formatters that will be used as default ones if no specific formatters are asked for + // Fix default contract resolver to use original names and not a camel case and add debugging aid while we're at it +#if NETFRAMEWORK mvc.AddJsonFormatters(); - // Fix default contract resolver to use original names and not a camel case - // Also add debugging aid while we're at it mvc.AddJsonOptions( +#else + mvc.AddNewtonsoftJson( +#endif options => { options.SerializerSettings.ContractResolver = new DefaultContractResolver(); diff --git a/ArchiSteamFarm/Json/Steam.cs b/ArchiSteamFarm/Json/Steam.cs index b34671502..1133fc9ab 100644 --- a/ArchiSteamFarm/Json/Steam.cs +++ b/ArchiSteamFarm/Json/Steam.cs @@ -22,7 +22,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; using System.Linq; using ArchiSteamFarm.Localization; using HtmlAgilityPack; @@ -214,7 +213,7 @@ namespace ArchiSteamFarm.Json { } } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] public class BooleanResponse { [JsonProperty(PropertyName = "success", Required = Required.Always)] public readonly bool Success; @@ -223,7 +222,7 @@ namespace ArchiSteamFarm.Json { protected BooleanResponse() { } } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] public sealed class ConfirmationDetails : BooleanResponse { internal MobileAuthenticator.Confirmation Confirmation { get; set; } internal ulong TradeOfferID { get; private set; } @@ -317,7 +316,7 @@ namespace ArchiSteamFarm.Json { } } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] public class EResultResponse { [JsonProperty(PropertyName = "success", Required = Required.Always)] public readonly EResult Result; @@ -326,7 +325,7 @@ namespace ArchiSteamFarm.Json { protected EResultResponse() { } } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] public class NumberResponse { [PublicAPI] public bool Success { get; private set; } @@ -416,7 +415,7 @@ namespace ArchiSteamFarm.Json { } } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class InventoryResponse : NumberResponse { [JsonProperty(PropertyName = "assets", Required = Required.DisallowNull)] internal readonly ImmutableHashSet Assets; @@ -669,7 +668,7 @@ namespace ArchiSteamFarm.Json { } } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class NewDiscoveryQueueResponse { [JsonProperty(PropertyName = "queue", Required = Required.Always)] internal readonly ImmutableHashSet Queue; @@ -678,7 +677,7 @@ namespace ArchiSteamFarm.Json { private NewDiscoveryQueueResponse() { } } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class RedeemWalletResponse : EResultResponse { [JsonProperty(PropertyName = "wallet", Required = Required.DisallowNull)] internal readonly InternalKeyDetails KeyDetails; @@ -701,7 +700,7 @@ namespace ArchiSteamFarm.Json { } } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class TradeOfferAcceptResponse { [JsonProperty(PropertyName = "needs_mobile_confirmation", Required = Required.DisallowNull)] internal readonly bool RequiresMobileConfirmation; @@ -723,7 +722,7 @@ namespace ArchiSteamFarm.Json { } } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class TradeOfferSendResponse { [JsonProperty(PropertyName = "needs_mobile_confirmation", Required = Required.DisallowNull)] internal readonly bool RequiresMobileConfirmation; @@ -755,7 +754,7 @@ namespace ArchiSteamFarm.Json { private TradeOfferSendResponse() { } } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class UserPrivacy { [JsonProperty(PropertyName = "eCommentPermission", Required = Required.Always)] internal readonly ECommentPermission CommentPermission; diff --git a/ArchiSteamFarm/MobileAuthenticator.cs b/ArchiSteamFarm/MobileAuthenticator.cs index b655391f8..212473849 100644 --- a/ArchiSteamFarm/MobileAuthenticator.cs +++ b/ArchiSteamFarm/MobileAuthenticator.cs @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; using System.Text; using System.Threading; @@ -33,7 +32,7 @@ using JetBrains.Annotations; using Newtonsoft.Json; namespace ArchiSteamFarm { - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class MobileAuthenticator { private const byte CodeDigits = 5; private const byte CodeInterval = 30; diff --git a/ArchiSteamFarm/RuntimeCompatibility.cs b/ArchiSteamFarm/RuntimeCompatibility.cs index c160d175e..d572cbb8c 100644 --- a/ArchiSteamFarm/RuntimeCompatibility.cs +++ b/ArchiSteamFarm/RuntimeCompatibility.cs @@ -25,6 +25,7 @@ using System.Threading.Tasks; using JetBrains.Annotations; #if NETFRAMEWORK +using Microsoft.AspNetCore.Hosting; using System.Collections.Generic; using System.Net.WebSockets; using System.Threading; @@ -119,6 +120,13 @@ namespace ArchiSteamFarm { } #if NETFRAMEWORK + [NotNull] + internal static IWebHostBuilder ConfigureWebHostDefaults([NotNull] this IWebHostBuilder builder, [NotNull] Action configure) { + configure(builder); + + return builder; + } + public static void Deconstruct(this KeyValuePair kv, out TKey key, out TValue value) { key = kv.Key; value = kv.Value; diff --git a/ArchiSteamFarm/Statistics.cs b/ArchiSteamFarm/Statistics.cs index e2d5f4c46..b9e2ce35a 100644 --- a/ArchiSteamFarm/Statistics.cs +++ b/ArchiSteamFarm/Statistics.cs @@ -22,7 +22,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -341,7 +340,7 @@ namespace ArchiSteamFarm { } } - [SuppressMessage("ReSharper", "FunctionComplexityOverflow")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "FunctionComplexityOverflow")] private async Task MatchActivelyRound(IReadOnlyCollection acceptedMatchableTypes, IDictionary GivenAssetIDs, ISet ReceivedAssetIDs)> triedSteamIDs) { if ((acceptedMatchableTypes == null) || (acceptedMatchableTypes.Count == 0) || (triedSteamIDs == null)) { Bot.ArchiLogger.LogNullError(nameof(acceptedMatchableTypes) + " || " + nameof(triedSteamIDs)); @@ -664,7 +663,7 @@ namespace ArchiSteamFarm { return skippedSetsThisRound.Count > 0; } - [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] private sealed class ListedUser { internal readonly HashSet MatchableTypes = new HashSet(); diff --git a/ArchiSteamFarm/nuget.config b/ArchiSteamFarm/nuget.config deleted file mode 100644 index f5534b3e0..000000000 --- a/ArchiSteamFarm/nuget.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/ArchiSteamFarm/rootDescriptor.xml b/ArchiSteamFarm/rootDescriptor.xml deleted file mode 100644 index d47f0c9ce..000000000 --- a/ArchiSteamFarm/rootDescriptor.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Dockerfile.Service.arm b/Dockerfile.Service.arm index 613ad25b7..19c628caf 100644 --- a/Dockerfile.Service.arm +++ b/Dockerfile.Service.arm @@ -6,9 +6,9 @@ RUN echo "node: $(node --version)" && \ npm ci && \ npm run-script deploy -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-dotnet +FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-dotnet ENV CONFIGURATION Release -ENV NET_CORE_VERSION netcoreapp2.2 +ENV NET_CORE_VERSION netcoreapp3.0 WORKDIR /app COPY --from=build-node /app/dist ASF-ui/dist COPY ArchiSteamFarm ArchiSteamFarm @@ -17,15 +17,15 @@ RUN dotnet --info && \ # TODO: Remove workaround for https://github.com/microsoft/msbuild/issues/3897 when it's no longer needed if [ -f "ArchiSteamFarm/Localization/Strings.zh-CN.resx" ]; then ln -s "Strings.zh-CN.resx" "ArchiSteamFarm/Localization/Strings.zh-Hans.resx"; fi && \ if [ -f "ArchiSteamFarm/Localization/Strings.zh-TW.resx" ]; then ln -s "Strings.zh-TW.resx" "ArchiSteamFarm/Localization/Strings.zh-Hant.resx"; fi && \ - dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/source' /nologo && \ - dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/source' /nologo && \ - dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/publish' /nologo /p:ASFVariant=generic /p:LinkDuringPublish=false && \ - cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm-Service.sh" "ArchiSteamFarm/out/publish/ArchiSteamFarm-Service.sh" + dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" /nologo && \ + dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" /nologo && \ + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out' /nologo /p:ASFVariant=generic /p:PublishTrimmed=false /p:UseAppHost=false && \ + cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm-Service.sh" "out/ArchiSteamFarm-Service.sh" -FROM mcr.microsoft.com/dotnet/core/runtime:2.2-stretch-slim-arm32v7 AS runtime +FROM mcr.microsoft.com/dotnet/core/runtime:3.0-buster-slim-arm32v7 AS runtime ENV ASPNETCORE_URLS= LABEL maintainer="JustArchi " EXPOSE 1242 WORKDIR /app -COPY --from=build-dotnet /app/ArchiSteamFarm/out/publish . +COPY --from=build-dotnet /app/out . ENTRYPOINT ["./ArchiSteamFarm-Service.sh", "--no-restart", "--process-required", "--system-required"] diff --git a/Dockerfile.Service.x64 b/Dockerfile.Service.x64 index fe79eef60..36a133e14 100644 --- a/Dockerfile.Service.x64 +++ b/Dockerfile.Service.x64 @@ -6,9 +6,9 @@ RUN echo "node: $(node --version)" && \ npm ci && \ npm run-script deploy -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-dotnet +FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-dotnet ENV CONFIGURATION Release -ENV NET_CORE_VERSION netcoreapp2.2 +ENV NET_CORE_VERSION netcoreapp3.0 WORKDIR /app COPY --from=build-node /app/dist ASF-ui/dist COPY ArchiSteamFarm ArchiSteamFarm @@ -17,15 +17,15 @@ RUN dotnet --info && \ # TODO: Remove workaround for https://github.com/microsoft/msbuild/issues/3897 when it's no longer needed if [ -f "ArchiSteamFarm/Localization/Strings.zh-CN.resx" ]; then ln -s "Strings.zh-CN.resx" "ArchiSteamFarm/Localization/Strings.zh-Hans.resx"; fi && \ if [ -f "ArchiSteamFarm/Localization/Strings.zh-TW.resx" ]; then ln -s "Strings.zh-TW.resx" "ArchiSteamFarm/Localization/Strings.zh-Hant.resx"; fi && \ - dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/source' /nologo && \ - dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/source' /nologo && \ - dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/publish' /nologo /p:ASFVariant=generic /p:LinkDuringPublish=false && \ - cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm-Service.sh" "ArchiSteamFarm/out/publish/ArchiSteamFarm-Service.sh" + dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" /nologo && \ + dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" /nologo && \ + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out' /nologo /p:ASFVariant=generic /p:PublishTrimmed=false /p:UseAppHost=false && \ + cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm-Service.sh" "out/ArchiSteamFarm-Service.sh" -FROM mcr.microsoft.com/dotnet/core/runtime:2.2-stretch-slim AS runtime +FROM mcr.microsoft.com/dotnet/core/runtime:3.0-buster-slim AS runtime ENV ASPNETCORE_URLS= LABEL maintainer="JustArchi " EXPOSE 1242 WORKDIR /app -COPY --from=build-dotnet /app/ArchiSteamFarm/out/publish . +COPY --from=build-dotnet /app/out . ENTRYPOINT ["./ArchiSteamFarm-Service.sh", "--no-restart", "--process-required", "--system-required"] diff --git a/Dockerfile.arm b/Dockerfile.arm index 82ee854e5..42342a59a 100644 --- a/Dockerfile.arm +++ b/Dockerfile.arm @@ -6,9 +6,9 @@ RUN echo "node: $(node --version)" && \ npm ci && \ npm run-script deploy -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-dotnet +FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-dotnet ENV CONFIGURATION Release -ENV NET_CORE_VERSION netcoreapp2.2 +ENV NET_CORE_VERSION netcoreapp3.0 WORKDIR /app COPY --from=build-node /app/dist ASF-ui/dist COPY ArchiSteamFarm ArchiSteamFarm @@ -17,15 +17,15 @@ RUN dotnet --info && \ # TODO: Remove workaround for https://github.com/microsoft/msbuild/issues/3897 when it's no longer needed if [ -f "ArchiSteamFarm/Localization/Strings.zh-CN.resx" ]; then ln -s "Strings.zh-CN.resx" "ArchiSteamFarm/Localization/Strings.zh-Hans.resx"; fi && \ if [ -f "ArchiSteamFarm/Localization/Strings.zh-TW.resx" ]; then ln -s "Strings.zh-TW.resx" "ArchiSteamFarm/Localization/Strings.zh-Hant.resx"; fi && \ - dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/source' /nologo && \ - dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/source' /nologo && \ - dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/publish' /nologo /p:ASFVariant=docker /p:LinkDuringPublish=false && \ - cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm.sh" "ArchiSteamFarm/out/publish/ArchiSteamFarm.sh" + dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" /nologo && \ + dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" /nologo && \ + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out' /nologo /p:ASFVariant=docker /p:PublishTrimmed=false /p:UseAppHost=false && \ + cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm.sh" "out/ArchiSteamFarm.sh" -FROM mcr.microsoft.com/dotnet/core/runtime:2.2-stretch-slim-arm32v7 AS runtime +FROM mcr.microsoft.com/dotnet/core/runtime:3.0-buster-slim-arm32v7 AS runtime ENV ASPNETCORE_URLS= LABEL maintainer="JustArchi " EXPOSE 1242 WORKDIR /app -COPY --from=build-dotnet /app/ArchiSteamFarm/out/publish . +COPY --from=build-dotnet /app/out . ENTRYPOINT ["./ArchiSteamFarm.sh", "--no-restart", "--process-required", "--system-required"] diff --git a/Dockerfile.x64 b/Dockerfile.x64 index 2bd53c64d..09a185a3f 100644 --- a/Dockerfile.x64 +++ b/Dockerfile.x64 @@ -6,9 +6,9 @@ RUN echo "node: $(node --version)" && \ npm ci && \ npm run-script deploy -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-dotnet +FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-dotnet ENV CONFIGURATION Release -ENV NET_CORE_VERSION netcoreapp2.2 +ENV NET_CORE_VERSION netcoreapp3.0 WORKDIR /app COPY --from=build-node /app/dist ASF-ui/dist COPY ArchiSteamFarm ArchiSteamFarm @@ -17,15 +17,15 @@ RUN dotnet --info && \ # TODO: Remove workaround for https://github.com/microsoft/msbuild/issues/3897 when it's no longer needed if [ -f "ArchiSteamFarm/Localization/Strings.zh-CN.resx" ]; then ln -s "Strings.zh-CN.resx" "ArchiSteamFarm/Localization/Strings.zh-Hans.resx"; fi && \ if [ -f "ArchiSteamFarm/Localization/Strings.zh-TW.resx" ]; then ln -s "Strings.zh-TW.resx" "ArchiSteamFarm/Localization/Strings.zh-Hant.resx"; fi && \ - dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/source' /nologo && \ - dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/source' /nologo && \ - dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out/publish' /nologo /p:ASFVariant=docker /p:LinkDuringPublish=false && \ - cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm.sh" "ArchiSteamFarm/out/publish/ArchiSteamFarm.sh" + dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" /nologo && \ + dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" /nologo && \ + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out' /nologo /p:ASFVariant=docker /p:PublishTrimmed=false /p:UseAppHost=false && \ + cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm.sh" "out/ArchiSteamFarm.sh" -FROM mcr.microsoft.com/dotnet/core/runtime:2.2-stretch-slim AS runtime +FROM mcr.microsoft.com/dotnet/core/runtime:3.0-buster-slim AS runtime ENV ASPNETCORE_URLS= LABEL maintainer="JustArchi " EXPOSE 1242 WORKDIR /app -COPY --from=build-dotnet /app/ArchiSteamFarm/out/publish . +COPY --from=build-dotnet /app/out . ENTRYPOINT ["./ArchiSteamFarm.sh", "--no-restart", "--process-required", "--system-required"] diff --git a/appveyor.yml b/appveyor.yml index 3821fb071..3e6abd5e0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,11 +9,11 @@ environment: CROWDIN_API_KEY: secure: oGuZaQo2z5/JkEYaKrD9Ing+TgwZ3qQVf+9Jdz73Fephy04z5rWPGCCtkjaMLTcY CROWDIN_PROJECT_IDENTIFIER: archisteamfarm - DOTNET_CHANNEL: 2.2 + DOTNET_CHANNEL: 3.0 DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_INSTALL_DIR: C:\Program Files\dotnet DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - NET_CORE_VERSION: netcoreapp2.2 + NET_CORE_VERSION: netcoreapp3.0 NET_FRAMEWORK_VERSION: net48 VARIANTS: generic generic-netf linux-arm linux-x64 osx-x64 win-x64 # NOTE: When modifying variants, don't forget to update ASF_VARIANT definitions in SharedInfo.cs! matrix: @@ -152,7 +152,7 @@ after_test: if ($variant -like 'generic*') { # TODO: Workaround https://github.com/mono/linker/issues/286 (don't forget to remove it from docker files too) - dotnet publish ArchiSteamFarm -c "$env:CONFIGURATION" -f "$targetFramework" -o "out\$variant" --no-restore /nologo "/p:ASFVariant=$variant" "/p:LinkDuringPublish=false" + dotnet publish ArchiSteamFarm -c "$env:CONFIGURATION" -f "$targetFramework" -o "out\$variant" --no-restore /nologo "/p:ASFVariant=$variant" "/p:PublishTrimmed=false" "/p:UseAppHost=false" } else { dotnet publish ArchiSteamFarm -c "$env:CONFIGURATION" -f "$targetFramework" -o "out\$variant" -r "$variant" --no-restore /nologo "/p:ASFVariant=$variant" "/p:LinkDuringPublish=false" } @@ -168,13 +168,7 @@ after_test: # Until https://github.com/dotnet/cli/issues/3267 happens, we'll hack dotnet binary icon on Windows and include .ico file on other platforms if ($targetFramework -ne "$env:NET_FRAMEWORK_VERSION") { - if (Test-Path "out\$variant\ArchiSteamFarm.exe" -PathType Leaf) { - tools\rcedit\rcedit-x64.exe "out\$variant\ArchiSteamFarm.exe" --set-icon 'resources\ASF.ico' - - if ($LastExitCode -ne 0) { - throw "Last command failed." - } - } else { + if (!(Test-Path "out\$variant\ArchiSteamFarm.exe" -PathType Leaf)) { Copy-Item 'resources\ASF.ico' "out\$variant\ArchiSteamFarm.ico" } } diff --git a/cc.sh b/cc.sh index 5dd1f62f8..f052e44e6 100755 --- a/cc.sh +++ b/cc.sh @@ -1,23 +1,23 @@ #!/usr/bin/env bash set -euo pipefail -TARGET_FRAMEWORK="netcoreapp2.2" +TARGET_FRAMEWORK="netcoreapp3.0" MAIN_PROJECT="ArchiSteamFarm" TESTS_PROJECT="${MAIN_PROJECT}.Tests" SOLUTION="${MAIN_PROJECT}.sln" CONFIGURATION="Release" -OUT="out/source" +OUT="out" ASF_UI=1 CLEAN=0 -LINK_DURING_PUBLISH=0 +PUBLISH_TRIMMED=0 PULL=1 SHARED_COMPILATION=1 TEST=1 PRINT_USAGE() { - echo "Usage: $0 [--clean] [--link-during-publish] [--no-asf-ui] [--no-pull] [--no-shared-compilation] [--no-test] [debug/release]" + echo "Usage: $0 [--clean] [--publish-trimmed] [--no-asf-ui] [--no-pull] [--no-shared-compilation] [--no-test] [debug/release]" } cd "$(dirname "$(readlink -f "$0")")" @@ -30,8 +30,8 @@ for ARG in "$@"; do --no-asf-ui) ASF_UI=0 ;; --clean) CLEAN=1 ;; --no-clean) CLEAN=0 ;; - --link-during-publish) LINK_DURING_PUBLISH=1 ;; - --no-link-during-publish) LINK_DURING_PUBLISH=0 ;; + --publish-trimmed) PUBLISH_TRIMMED=1 ;; + --no-publish-trimmed) PUBLISH_TRIMMED=0 ;; --pull) PULL=1 ;; --no-pull) PULL=0 ;; --shared-compilation) SHARED_COMPILATION=1 ;; @@ -75,16 +75,16 @@ if [[ "$ASF_UI" -eq 1 ]]; then ) # ASF's output www folder needs cleaning as well - rm -rf "${MAIN_PROJECT}/${OUT}/www" + rm -rf "${OUT}/www" else echo "WARNING: ASF-ui dependencies are missing, skipping build of ASF-ui..." fi fi -DOTNET_FLAGS=(-c "$CONFIGURATION" -f "$TARGET_FRAMEWORK" -o "$OUT" '/nologo') +DOTNET_FLAGS=(-c "$CONFIGURATION" -f "$TARGET_FRAMEWORK" '/nologo') -if [[ "$LINK_DURING_PUBLISH" -eq 0 ]]; then - DOTNET_FLAGS+=('/p:LinkDuringPublish=false') +if [[ "$PUBLISH_TRIMMED" -eq 0 ]]; then + DOTNET_FLAGS+=('/p:PublishTrimmed=false') fi if [[ "$SHARED_COMPILATION" -eq 0 ]]; then @@ -93,14 +93,14 @@ fi if [[ "$CLEAN" -eq 1 ]]; then dotnet clean "${DOTNET_FLAGS[@]}" - rm -rf "${MAIN_PROJECT:?}/${OUT}" "${TESTS_PROJECT:?}/${OUT}" + rm -rf "$OUT" fi if [[ "$TEST" -eq 1 ]]; then dotnet test "$TESTS_PROJECT" "${DOTNET_FLAGS[@]}" fi -dotnet publish "$MAIN_PROJECT" "${DOTNET_FLAGS[@]}" +dotnet publish "$MAIN_PROJECT" "${DOTNET_FLAGS[@]}" -o "$OUT" echo echo "SUCCESS: Compilation finished successfully! :)" diff --git a/run.sh b/run.sh index ed65da380..1524e7343 100755 --- a/run.sh +++ b/run.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -BINARY_PATH="$(dirname "$(readlink -f "$0")")/ArchiSteamFarm/out/source" +BINARY_PATH="$(dirname "$(readlink -f "$0")")/out" CONFIG_PATH="config/ASF.json" if [[ ! -d "$BINARY_PATH" ]]; then diff --git a/tools/rcedit/LICENSE.md b/tools/rcedit/LICENSE.md deleted file mode 100644 index 493db50ed..000000000 --- a/tools/rcedit/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2013 GitHub Inc. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/rcedit/README.md b/tools/rcedit/README.md deleted file mode 100644 index e186520a8..000000000 --- a/tools/rcedit/README.md +++ /dev/null @@ -1,10 +0,0 @@ -rcedit -=================== - -**[Latest release](https://github.com/electron/rcedit/releases/latest)** - -**[Source](https://github.com/electron/rcedit)** - ---- - -This tool is being used by our CI for injecting ASF icon into Windows dotnet binary, until https://github.com/dotnet/cli/issues/3267 is eventually dealt with. diff --git a/tools/rcedit/rcedit-x64.exe b/tools/rcedit/rcedit-x64.exe deleted file mode 100644 index 36764c62d..000000000 Binary files a/tools/rcedit/rcedit-x64.exe and /dev/null differ