diff --git a/.travis.yml b/.travis.yml index 77680f8b7..f74980c0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,16 +31,16 @@ script: npm ci --no-progress --prefix ASF-ui npm run-script deploy --no-progress --prefix ASF-ui - 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 + 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:PublishTrimmed=false" "/p:UseAppHost=false" + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/${1}" --no-restore --nologo "/p:ASFVariant=$1" "/p:UseAppHost=false" else - dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/${1}" -r "$1" --no-restore /nologo "/p:ASFVariant=$1" "/p:LinkDuringPublish=false" + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o "out/${1}" -r "$1" --no-restore --nologo "/p:ASFVariant=$1" "/p:PublishTrimmed=true" "/p:PublishSingleFile=true" fi # If we include any overlay for this variant, copy it to output directory @@ -49,6 +49,7 @@ script: fi } + dotnet clean ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo dotnet restore ArchiSteamFarm jobs="" diff --git a/ArchiSteamFarm/ArchiSteamFarm.csproj b/ArchiSteamFarm/ArchiSteamFarm.csproj index 3f28d5ddf..0ccbce344 100644 --- a/ArchiSteamFarm/ArchiSteamFarm.csproj +++ b/ArchiSteamFarm/ArchiSteamFarm.csproj @@ -8,7 +8,7 @@ true 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. + ASF is a C# application with primary purpose of idling Steam cards from multiple accounts simultaneously. none 4.1.0.9 true @@ -19,7 +19,6 @@ ../resources/ASF.ico Apache-2.0 https://github.com/JustArchiNET/ArchiSteamFarm - false Git https://github.com/JustArchiNET/ArchiSteamFarm.git linux-arm;linux-x64;osx-x64;win-x64 @@ -110,12 +109,13 @@ - %(RecursiveDir)%(Filename)%(Extension) PreserveNewest + true + %(RecursiveDir)%(Filename)%(Extension) - www\%(RecursiveDir)%(Filename)%(Extension) PreserveNewest + www\%(RecursiveDir)%(Filename)%(Extension) diff --git a/ArchiSteamFarm/SharedInfo.cs b/ArchiSteamFarm/SharedInfo.cs index 568291352..ec62b3570 100644 --- a/ArchiSteamFarm/SharedInfo.cs +++ b/ArchiSteamFarm/SharedInfo.cs @@ -20,6 +20,7 @@ // limitations under the License. using System; +using System.Diagnostics; using System.IO; using System.Reflection; using ArchiSteamFarm.Plugins; @@ -61,7 +62,34 @@ namespace ArchiSteamFarm { internal const string UpdateDirectory = "_old"; internal const string WebsiteDirectory = "www"; - internal static string HomeDirectory => Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location ?? throw new ArgumentNullException(nameof(HomeDirectory))); + internal static string HomeDirectory { + get { + // We're aiming to handle two possible cases here, classic publish and single-file publish + // Firstly, we'll get the path to the binary that is running our code + string binaryPath; + + using (Process process = Process.GetCurrentProcess()) { + binaryPath = process.MainModule?.FileName; + } + + if (string.IsNullOrEmpty(binaryPath)) { + throw new ArgumentNullException(nameof(binaryPath)); + } + + // Now we need to check what that binary actually is + return Path.GetFileNameWithoutExtension(binaryPath) switch { + // This path goes to our own binary, so the user is using OS-specific build, single-file or not, we'll return path to location of that binary then + AssemblyName => Path.GetDirectoryName(binaryPath), + + // This path goes to third-party binary, so the user is using our generic build, we'll return our base directory then + "dotnet" => AppContext.BaseDirectory, + "mono" => AppContext.BaseDirectory, + + // Unhandled case + _ => throw new ArgumentOutOfRangeException(nameof(binaryPath)) + }; + } + } [NotNull] internal static string ProgramIdentifier => PublicIdentifier + " V" + Version + " (" + BuildInfo.Variant + "/" + ModuleVersion + " | " + OS.Variant + ")"; diff --git a/Dockerfile.Service.arm b/Dockerfile.Service.arm index c70fdd31d..1d9bc07a6 100644 --- a/Dockerfile.Service.arm +++ b/Dockerfile.Service.arm @@ -17,9 +17,10 @@ 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" /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 && \ + dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet clean ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out' --nologo /p:ASFVariant=generic /p:UseAppHost=false && \ cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm-Service.sh" "out/ArchiSteamFarm-Service.sh" FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim-arm32v7 AS runtime diff --git a/Dockerfile.Service.x64 b/Dockerfile.Service.x64 index 4dac5d299..db9346095 100644 --- a/Dockerfile.Service.x64 +++ b/Dockerfile.Service.x64 @@ -17,9 +17,10 @@ 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" /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 && \ + dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet clean ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out' --nologo /p:ASFVariant=generic /p:UseAppHost=false && \ cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm-Service.sh" "out/ArchiSteamFarm-Service.sh" FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS runtime diff --git a/Dockerfile.arm b/Dockerfile.arm index 2b818d437..b21b4431f 100644 --- a/Dockerfile.arm +++ b/Dockerfile.arm @@ -17,9 +17,10 @@ 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" /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 && \ + dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet clean ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out' --nologo /p:ASFVariant=docker /p:UseAppHost=false && \ cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm.sh" "out/ArchiSteamFarm.sh" FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim-arm32v7 AS runtime diff --git a/Dockerfile.x64 b/Dockerfile.x64 index e4c05976c..b661d245f 100644 --- a/Dockerfile.x64 +++ b/Dockerfile.x64 @@ -17,9 +17,10 @@ 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" /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 && \ + dotnet build ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet test ArchiSteamFarm.Tests -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet clean ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" --nologo && \ + dotnet publish ArchiSteamFarm -c "$CONFIGURATION" -f "$NET_CORE_VERSION" -o 'out' --nologo /p:ASFVariant=docker /p:UseAppHost=false && \ cp "ArchiSteamFarm/overlay/generic/ArchiSteamFarm.sh" "out/ArchiSteamFarm.sh" FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS runtime diff --git a/appveyor.yml b/appveyor.yml index b232ebc6f..512c65f19 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -98,7 +98,7 @@ build_script: } - dotnet build ArchiSteamFarm -c "$env:CONFIGURATION" -f "$env:NET_CORE_VERSION" /nologo + dotnet build ArchiSteamFarm -c "$env:CONFIGURATION" -f "$env:NET_CORE_VERSION" --nologo if ($LastExitCode -ne 0) { @@ -106,7 +106,7 @@ build_script: } - dotnet build ArchiSteamFarm.CustomPlugins.ExamplePlugin -c "$env:CONFIGURATION" -f "$env:NET_CORE_VERSION" /nologo + dotnet build ArchiSteamFarm.CustomPlugins.ExamplePlugin -c "$env:CONFIGURATION" -f "$env:NET_CORE_VERSION" --nologo if ($LastExitCode -ne 0) { @@ -121,7 +121,7 @@ test_script: $ProgressPreference = 'SilentlyContinue' - dotnet test ArchiSteamFarm.Tests -c "$env:CONFIGURATION" -f "$env:NET_CORE_VERSION" /nologo + dotnet test ArchiSteamFarm.Tests -c "$env:CONFIGURATION" -f "$env:NET_CORE_VERSION" --nologo if ($LastExitCode -ne 0) { @@ -155,9 +155,9 @@ 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:PublishTrimmed=false" "/p:UseAppHost=false" + dotnet publish ArchiSteamFarm -c "$env:CONFIGURATION" -f "$targetFramework" -o "out\$variant" --no-restore --nologo "/p:ASFVariant=$variant" "/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" + dotnet publish ArchiSteamFarm -c "$env:CONFIGURATION" -f "$targetFramework" -o "out\$variant" -r "$variant" --no-restore --nologo "/p:ASFVariant=$variant" "/p:PublishTrimmed=true" "/p:PublishSingleFile=true" } if ($LastExitCode -ne 0) { @@ -209,9 +209,22 @@ after_test: } + dotnet clean ArchiSteamFarm -c "$env:CONFIGURATION" -f "$env:NET_CORE_VERSION" --nologo + + + if ($LastExitCode -ne 0) { + throw "Last command failed." + } + + dotnet restore ArchiSteamFarm + if ($LastExitCode -ne 0) { + throw "Last command failed." + } + + foreach ($variant in $env:VARIANTS.Split([char[]] $null, [System.StringSplitOptions]::RemoveEmptyEntries)) { Start-Job -Name "$variant" $PublishBlock -ArgumentList "$variant" } diff --git a/cc.sh b/cc.sh index 4f0a41237..cd316063f 100755 --- a/cc.sh +++ b/cc.sh @@ -11,13 +11,12 @@ OUT="out" ASF_UI=1 CLEAN=0 -PUBLISH_TRIMMED=0 PULL=1 SHARED_COMPILATION=1 TEST=1 PRINT_USAGE() { - echo "Usage: $0 [--clean] [--publish-trimmed] [--no-asf-ui] [--no-pull] [--no-shared-compilation] [--no-test] [debug/release]" + echo "Usage: $0 [--clean] [--no-asf-ui] [--no-pull] [--no-shared-compilation] [--no-test] [debug/release]" } cd "$(dirname "$(readlink -f "$0")")" @@ -30,8 +29,6 @@ for ARG in "$@"; do --no-asf-ui) ASF_UI=0 ;; --clean) CLEAN=1 ;; --no-clean) CLEAN=0 ;; - --publish-trimmed) PUBLISH_TRIMMED=1 ;; - --no-publish-trimmed) PUBLISH_TRIMMED=0 ;; --pull) PULL=1 ;; --no-pull) PULL=0 ;; --shared-compilation) SHARED_COMPILATION=1 ;; @@ -83,10 +80,6 @@ fi DOTNET_FLAGS="-c $CONFIGURATION -f $TARGET_FRAMEWORK /nologo" -if [ "$PUBLISH_TRIMMED" -eq 0 ]; then - DOTNET_FLAGS="$DOTNET_FLAGS /p:PublishTrimmed=false" -fi - if [ "$SHARED_COMPILATION" -eq 0 ]; then DOTNET_FLAGS="$DOTNET_FLAGS /p:UseSharedCompilation=false" fi