Update ASF to .NET Core 3.0 (#1427)

* Initial bump to .net core 3.0

* Update cc.sh

* Update appveyor.yml

* Update ArchiSteamFarm.csproj

* Update appveyor.yml

* Update .travis.yml

* Build corrections

* Cleanup

* Update .travis.yml

* Don't publish trimmed for now

* Update ArchiSteamFarm.csproj
This commit is contained in:
Łukasz Domeradzki 2019-09-26 20:28:25 +02:00 committed by GitHub
parent 12cc482540
commit 5b4867c387
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 213 additions and 251 deletions

View file

@ -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

View file

@ -18,11 +18,11 @@
</PropertyGroup>
<PropertyGroup Condition="'$(OS)' == 'Windows_NT' OR '$(ASFNetFramework)' != ''">
<TargetFrameworks>netcoreapp2.2;net48</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;net48</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(OS)' != 'Windows_NT' AND '$(ASFNetFramework)' == ''">
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">

View file

@ -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)]

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="dependencyversion" value="Highest" />
</config>
<packageSources>
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
</packageSources>
</configuration>

View file

@ -19,11 +19,11 @@
</PropertyGroup>
<PropertyGroup Condition="'$(OS)' == 'Windows_NT' OR '$(ASFNetFramework)' != ''">
<TargetFrameworks>netcoreapp2.2;net48</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;net48</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(OS)' != 'Windows_NT' AND '$(ASFNetFramework)' == ''">
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="dependencyversion" value="Highest" />
</config>
<packageSources>
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
</packageSources>
</configuration>

View file

@ -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<uint> wantedRealAppIDs = null, IReadOnlyCollection<Steam.Asset.EType> wantedTypes = null) {
if ((appID == 0) || (contextID == 0)) {
Bot.ArchiLogger.LogNullError(nameof(appID) + " || " + nameof(contextID));

View file

@ -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<uint, string> Items;

View file

@ -2,16 +2,15 @@
<PropertyGroup>
<ApplicationIcon>ASF.ico</ApplicationIcon>
<AssemblyVersion>4.0.4.4</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<Authors>JustArchi</Authors>
<Company>JustArchi</Company>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
<CrossGenDuringPublish>false</CrossGenDuringPublish>
<Copyright>Copyright © ArchiSteamFarm 2015-2019</Copyright>
<DefaultItemExcludes>$(DefaultItemExcludes);config/**;debug/**;out/**;overlay/**</DefaultItemExcludes>
<Description>ASF is an application that allows you to farm steam cards using multiple steam accounts simultaneously.</Description>
<ErrorReport>none</ErrorReport>
<FileVersion>4.0.4.4</FileVersion>
<FileVersion>4.1.0.0</FileVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>latest</LangVersion>
<NoWarn>1591</NoWarn>
@ -19,6 +18,7 @@
<PackageIconUrl>https://github.com/JustArchiNET/ArchiSteamFarm/raw/master/resources/ASF.ico</PackageIconUrl>
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/JustArchiNET/ArchiSteamFarm</PackageProjectUrl>
<PublishTrimmed>false</PublishTrimmed>
<RepositoryType>Git</RepositoryType>
<RepositoryUrl>https://github.com/JustArchiNET/ArchiSteamFarm.git</RepositoryUrl>
<RuntimeIdentifiers>linux-arm;linux-x64;osx-x64;win-x64</RuntimeIdentifiers>
@ -27,11 +27,11 @@
</PropertyGroup>
<PropertyGroup Condition="'$(OS)' == 'Windows_NT' OR '$(ASFNetFramework)' != ''">
<TargetFrameworks>netcoreapp2.2;net48</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;net48</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(OS)' != 'Windows_NT' AND '$(ASFNetFramework)' == ''">
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
@ -45,16 +45,6 @@
<DefineConstants>$(DefineConstants);ASF_VARIANT_$(ASFVariant.Replace('-', '_').ToUpperInvariant())</DefineConstants>
</PropertyGroup>
<ItemGroup>
<LinkerRootDescriptors Include="rootDescriptor.xml" />
</ItemGroup>
<!-- Workaround for https://github.com/Microsoft/msbuild/issues/3350 -->
<!-- TODO: Revisit this with msbuild 16.0+ (probably .NET Core 3.0) -->
<ItemGroup>
<CoreCompileCache Include="$(DefineConstants)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="4.0.0">
<PrivateAssets>all</PrivateAssets>
@ -64,16 +54,6 @@
<PackageReference Include="Humanizer" Version="2.7.2" />
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Markdig.Signed" Version="0.17.1" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="3.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.6.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3-beta1" />
<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.0.0" />
@ -88,12 +68,21 @@
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.2'">
<PackageReference Include="ILLink.Tasks" Version="0.1.5-preview-1841731" />
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.6.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="3.0.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.6.0" />
<Reference Include="System.Net.Http">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Net.Http.dll</HintPath>

View file

@ -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<HashSet<Steam.Asset>> GetInventory(ulong steamID = 0, uint appID = Steam.Asset.SteamAppID, ulong contextID = Steam.Asset.SteamCommunityContextID, bool? marketable = null, bool? tradable = null, IReadOnlyCollection<uint> wantedRealAppIDs = null, IReadOnlyCollection<Steam.Asset.EType> 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));

View file

@ -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;

View file

@ -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;

View file

@ -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<T> 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<T>.Add([NotNull] T item) => Add(item);
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

View file

@ -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<T> GetEnumerator() => new ConcurrentEnumerator<T>(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<T> collection) {

View file

@ -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<string, string> 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<string> ResponseRedeem(ulong steamID, string keysText, ERedeemFlags redeemFlags = ERedeemFlags.None) {
if ((steamID == 0) || string.IsNullOrEmpty(keysText)) {
Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(keysText));

View file

@ -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;

View file

@ -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<Startup>();
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<Startup>();
}
);
// 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();

View file

@ -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";

View file

@ -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 {
/// <summary>
/// Specifies the command that will be executed by ASF.

View file

@ -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<PathString>("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<ApiAuthenticationMiddleware>());
@ -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<Assembly> 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();

View file

@ -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<Asset> 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<uint> 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;

View file

@ -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;

View file

@ -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<IWebHostBuilder> configure) {
configure(builder);
return builder;
}
public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> kv, out TKey key, out TValue value) {
key = kv.Key;
value = kv.Value;

View file

@ -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<bool> MatchActivelyRound(IReadOnlyCollection<Steam.Asset.EType> acceptedMatchableTypes, IDictionary<ulong, (byte Tries, ISet<ulong> GivenAssetIDs, ISet<ulong> 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<Steam.Asset.EType> MatchableTypes = new HashSet<Steam.Asset.EType>();

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="dependencyversion" value="Highest" />
</config>
<packageSources>
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
</packageSources>
</configuration>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<linker>
<assembly fullname="System.ComponentModel.TypeConverter">
<type fullname="System.ComponentModel.*" required="true" />
</assembly>
</linker>

View file

@ -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 <JustArchi@JustArchi.net>"
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"]

View file

@ -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 <JustArchi@JustArchi.net>"
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"]

View file

@ -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 <JustArchi@JustArchi.net>"
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"]

View file

@ -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 <JustArchi@JustArchi.net>"
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"]

View file

@ -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"
}
}

24
cc.sh
View file

@ -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! :)"

2
run.sh
View file

@ -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

View file

@ -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.

View file

@ -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.

Binary file not shown.