New: Multi target net framework 4.6.2 and net core 3.0

This commit is contained in:
ta264 2019-10-28 21:30:08 +00:00 committed by Qstick
commit 8fe924fdcd
99 changed files with 898 additions and 852 deletions

View file

@ -5,7 +5,8 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64;linux-arm;linux-arm64</RuntimeIdentifiers>
<ExcludedRuntimeFrameworkPairs>win-x64:net462;osx-x64:net462;linux-arm:net462;linux-arm64:net462</ExcludedRuntimeFrameworkPairs>
<LidarrRootDir>$(MSBuildThisFileDirectory)..\</LidarrRootDir>

Binary file not shown.

View file

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Marr.Data\Marr.Data.csproj" />
@ -17,6 +17,6 @@
<PackageReference Include="Nancy.Authentication.Forms" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="NLog" Version="4.6.7" />
<PackageReference Include="System.IO.Abstractions" Version="4.0.11" />
<PackageReference Include="System.IO.Abstractions" Version="6.0.38" />
</ItemGroup>
</Project>

View file

@ -59,7 +59,7 @@ namespace Lidarr.Api.V1.System
AppData = _appFolderInfo.GetAppDataPath(),
OsName = _osInfo.Name,
OsVersion = _osInfo.Version,
IsMonoRuntime = PlatformInfo.IsMono,
IsNetCore = PlatformInfo.IsNetCore,
IsMono = PlatformInfo.IsMono,
IsLinux = OsInfo.IsLinux,
IsOsx = OsInfo.IsOsx,

View file

@ -6,7 +6,6 @@ using Nancy;
using Nancy.Bootstrapper;
using NLog;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
namespace Lidarr.Http.Extensions.Pipelines
{
@ -81,7 +80,7 @@ namespace Lidarr.Http.Extensions.Pipelines
private static bool ContentLengthIsTooSmall(Response response)
{
var contentLength = response.Headers.GetValueOrDefault("Content-Length");
var contentLength = response.Headers.TryGetValue("Content-Length", out var value) ? value : null;
if (contentLength != null && long.Parse(contentLength) < 1024)
{
@ -93,7 +92,7 @@ namespace Lidarr.Http.Extensions.Pipelines
private static bool AlreadyGzipEncoded(Response response)
{
var contentEncoding = response.Headers.GetValueOrDefault("Content-Encoding");
var contentEncoding = response.Headers.TryGetValue("Content-Encoding", out var value) ? value : null;
if (contentEncoding == "gzip")
{

View file

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="8.4.0" />

View file

@ -38,15 +38,6 @@ namespace Marr.Data
private DbCommand _command;
/// <summary>
/// Initializes a DataMapper for the given provider type and connection string.
/// </summary>
/// <param name="providerName">Ex: </param>
/// <param name="connectionString">The database connection string.</param>
public DataMapper(string providerName, string connectionString)
: this(DbProviderFactories.GetFactory(providerName), connectionString)
{ }
/// <summary>
/// A database provider agnostic initialization.
/// </summary>

View file

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<AssemblyVersion>3.17.0.0</AssemblyVersion>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>

View file

@ -1,68 +0,0 @@
/* Copyright (C) 2008 - 2011 Jordan Marr
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>. */
using System;
using System.Data;
using System.Data.OleDb;
namespace Marr.Data.Parameters
{
public class OleDbTypeBuilder : IDbTypeBuilder
{
public Enum GetDbType(Type type)
{
if (type == typeof(String))
return OleDbType.VarChar;
if (type == typeof(Int32))
return OleDbType.Integer;
if (type == typeof(Decimal))
return OleDbType.Decimal;
if (type == typeof(DateTime))
return OleDbType.DBTimeStamp;
if (type == typeof(Boolean))
return OleDbType.Boolean;
if (type == typeof(Int16))
return OleDbType.SmallInt;
if (type == typeof(Int64))
return OleDbType.BigInt;
if (type == typeof(Double))
return OleDbType.Double;
if (type == typeof(Byte))
return OleDbType.Binary;
if (type == typeof(Byte[]))
return OleDbType.VarBinary;
if (type == typeof(Guid))
return OleDbType.Guid;
return OleDbType.Variant;
}
public void SetDbType(IDbDataParameter param, Enum dbType)
{
var oleDbParam = (OleDbParameter)param;
oleDbParam.OleDbType = (OleDbType)dbType;
}
}
}

View file

@ -1,71 +0,0 @@
/* Copyright (C) 2008 - 2011 Jordan Marr
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>. */
using System;
using System.Data;
using System.Data.SqlClient;
namespace Marr.Data.Parameters
{
public class SqlDbTypeBuilder : IDbTypeBuilder
{
public Enum GetDbType(Type type)
{
if (type == typeof(String))
return SqlDbType.VarChar;
if (type == typeof(Int32))
return SqlDbType.Int;
if (type == typeof(Decimal))
return SqlDbType.Decimal;
if (type == typeof(DateTime))
return SqlDbType.DateTime;
if (type == typeof(Boolean))
return SqlDbType.Bit;
if (type == typeof(Int16))
return SqlDbType.SmallInt;
if (type == typeof(Int64))
return SqlDbType.BigInt;
if (type == typeof(Double))
return SqlDbType.Float;
if (type == typeof(Char))
return SqlDbType.Char;
if (type == typeof(Byte))
return SqlDbType.Binary;
if (type == typeof(Byte[]))
return SqlDbType.VarBinary;
if (type == typeof(Guid))
return SqlDbType.UniqueIdentifier;
return SqlDbType.Variant;
}
public void SetDbType(IDbDataParameter param, Enum dbType)
{
var sqlDbParam = (SqlParameter)param;
sqlDbParam.SqlDbType = (SqlDbType)dbType;
}
}
}

View file

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>9.0.21022</Version>
</PropertyGroup>

View file

@ -1,10 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.41" />
<PackageReference Include="NBuilder" Version="6.0.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="coverlet.collector" Version="1.1.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Core\Lidarr.Core.csproj" />
<ProjectReference Include="..\NzbDrone.Test.Common\Lidarr.Test.Common.csproj" />

View file

@ -1,8 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.41" />
<PackageReference Include="Selenium.Firefox.WebDriver" Version="0.24.0" />
<PackageReference Include="Selenium.Support" Version="3.141.0" />
</ItemGroup>

View file

@ -170,7 +170,7 @@ namespace NzbDrone.Common.Test.Http
var response = Subject.Get<HttpBinResource>(request);
response.Resource.Headers["Accept-Encoding"].ToString().Should().Be(compression);
response.Headers.ContentLength.Should().BeLessOrEqualTo(response.Content.Length);
response.Resource.Gzipped.Should().BeTrue();
}
[TestCase(HttpStatusCode.Unauthorized)]
@ -723,6 +723,7 @@ namespace NzbDrone.Common.Test.Http
public string Origin { get; set; }
public string Url { get; set; }
public string Data { get; set; }
public bool Gzipped { get; set; }
}
public class HttpCookieResource

View file

@ -1,13 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.41" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="coverlet.collector" Version="1.1.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Host\Lidarr.Host.csproj" />
<ProjectReference Include="..\NzbDrone.Test.Common\Lidarr.Test.Common.csproj" />
<ProjectReference Include="..\NzbDrone.Test.Dummy\Lidarr.Test.Dummy.csproj" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.ServiceProcess" />
</ItemGroup>
</Project>

View file

@ -224,7 +224,7 @@ namespace NzbDrone.Common.Test
public void get_actual_casing_should_return_actual_casing_for_local_dir_in_windows()
{
WindowsOnly();
var path = Directory.GetCurrentDirectory().Replace("c:\\","C:\\").Replace("system32", "System32");
var path = Directory.GetCurrentDirectory().Replace("c:\\","C:\\").Replace("d:\\","D:\\").Replace("system32", "System32");
path.ToUpper().GetActualCasing().Should().Be(path);
path.ToLower().GetActualCasing().Should().Be(path);
@ -281,7 +281,7 @@ namespace NzbDrone.Common.Test
[Test]
public void GetUpdateClientExePath()
{
GetIAppDirectoryInfo().GetUpdateClientExePath(new Version("0.7.1.1381")).Should().BeEquivalentTo(@"C:\Temp\lidarr_update\Lidarr.Update.exe".AsOsAgnostic());
GetIAppDirectoryInfo().GetUpdateClientExePath(PlatformType.DotNet).Should().BeEquivalentTo(@"C:\Temp\lidarr_update\Lidarr.Update.exe".AsOsAgnostic());
}
[Test]

View file

@ -6,6 +6,7 @@ using System.Linq;
using System.Threading;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Model;
using NzbDrone.Common.Processes;
using NzbDrone.Test.Common;
@ -123,7 +124,17 @@ namespace NzbDrone.Common.Test
{
var processStarted = new ManualResetEventSlim();
var path = Path.Combine(TestContext.CurrentContext.TestDirectory, DummyApp.DUMMY_PROCCESS_NAME + ".exe");
string suffix;
if (OsInfo.IsWindows || PlatformInfo.IsMono)
{
suffix = ".exe";
}
else
{
suffix = "";
}
var path = Path.Combine(TestContext.CurrentContext.TestDirectory, DummyApp.DUMMY_PROCCESS_NAME + suffix);
var process = Subject.Start(path, onOutputDataReceived: (string data) => {
if (data.StartsWith("Dummy process. ID:"))
{

View file

@ -4,13 +4,13 @@ using System.ServiceProcess;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Processes;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.Categories;
namespace NzbDrone.Common.Test
{
[TestFixture]
[Timeout(15000)]
public class ServiceProviderFixture : TestBase<ServiceProvider>
{
private const string ALWAYS_INSTALLED_SERVICE = "SCardSvr"; //Smart Card
@ -20,6 +20,9 @@ namespace NzbDrone.Common.Test
public void Setup()
{
WindowsOnly();
Mocker.SetConstant<IProcessProvider>(Mocker.Resolve<ProcessProvider>());
CleanupService();
}

View file

@ -6,6 +6,12 @@ using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Messaging;
using TinyIoC;
#if NETCOREAPP3_0
using System.IO;
using System.Runtime.Loader;
using System.Runtime.InteropServices;
#endif
namespace NzbDrone.Common.Composition
{
public abstract class ContainerBuilderBase
@ -21,15 +27,67 @@ namespace NzbDrone.Common.Composition
assemblies.Add(OsInfo.IsWindows ? "Lidarr.Windows" : "Lidarr.Mono");
assemblies.Add("Lidarr.Common");
#if !NETCOREAPP3_0
foreach (var assembly in assemblies)
{
_loadedTypes.AddRange(Assembly.Load(assembly).GetTypes());
}
#else
var _startupPath = AppDomain.CurrentDomain.BaseDirectory;
foreach (var assemblyName in assemblies)
{
_loadedTypes.AddRange(AssemblyLoadContext.Default.LoadFromAssemblyPath(Path.Combine(_startupPath, $"{assemblyName}.dll")).GetTypes());
}
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ContainerResolveEventHandler);
RegisterSQLiteResolver();
#endif
Container = new Container(new TinyIoCContainer(), _loadedTypes);
AutoRegisterInterfaces();
Container.Register(args);
}
}
#if NETCOREAPP3_0
private static Assembly ContainerResolveEventHandler(object sender, ResolveEventArgs args)
{
var _resolver = new AssemblyDependencyResolver(args.RequestingAssembly.Location);
var assemblyPath = _resolver.ResolveAssemblyToPath(new AssemblyName(args.Name));
if (assemblyPath == null)
{
return null;
}
return AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath);
}
public static void RegisterSQLiteResolver()
{
// This ensures we look for sqlite3 using libsqlite3.so.0 on Linux and not libsqlite3.so which
// is less likely to exist.
var sqliteAssembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "System.Data.SQLite.dll")
);
try
{
NativeLibrary.SetDllImportResolver(sqliteAssembly, LoadSqliteNativeLib);
}
catch (InvalidOperationException)
{
// This can only be set once per assembly
// Catch required for NzbDrone.Host tests
}
}
private static IntPtr LoadSqliteNativeLib(string libraryName, Assembly assembly, DllImportSearchPath? dllImportSearchPath)
{
var mappedName = OsInfo.IsLinux && libraryName == "sqlite3" ? "libsqlite3.so.0" : libraryName;
return NativeLibrary.Load(mappedName, assembly, dllImportSearchPath);
}
#endif
private void AutoRegisterInterfaces()
{

View file

@ -74,21 +74,26 @@ namespace NzbDrone.Common.EnvironmentInfo
try
{
var configHome = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
if (configHome == "/.config" ||
// It seems that DoNotVerify is the mono behaviour even though .net docs specify a blank string
// should be returned if the data doesn't exist. For compatibility with .net core, explicitly
// set DoNotVerify (which makes sense given we're explicitly checking that the folder exists)
var configHome = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify);
if (configHome.IsNullOrWhiteSpace() ||
configHome == "/.config" ||
configHome.EndsWith("/.config") && !_diskProvider.FolderExists(configHome.GetParentPath()) ||
!_diskProvider.FolderExists(configHome))
{
// Tell mono to use appData/.config as ApplicationData folder.
// Tell mono/netcore to use appData/.config as ApplicationData folder.
Environment.SetEnvironmentVariable("XDG_CONFIG_HOME", Path.Combine(_appFolderInfo.AppDataFolder, ".config"));
}
var dataHome = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
if (dataHome == "/.local/share" ||
var dataHome = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.DoNotVerify);
if (dataHome.IsNullOrWhiteSpace() ||
dataHome == "/.local/share" ||
dataHome.EndsWith("/.local/share") && !_diskProvider.FolderExists(dataHome.GetParentPath().GetParentPath()) ||
!_diskProvider.FolderExists(dataHome))
{
// Tell mono to use appData/.config/share as LocalApplicationData folder.
// Tell mono/netcore to use appData/.config/share as LocalApplicationData folder.
Environment.SetEnvironmentVariable("XDG_DATA_HOME", Path.Combine(_appFolderInfo.AppDataFolder, ".config/share"));
}
}

View file

@ -34,7 +34,7 @@ namespace NzbDrone.Common.EnvironmentInfo
}
else
{
AppDataFolder = Path.Combine(Environment.GetFolderPath(DATA_SPECIAL_FOLDER, Environment.SpecialFolderOption.None), "Lidarr");
AppDataFolder = Path.Combine(Environment.GetFolderPath(DATA_SPECIAL_FOLDER, Environment.SpecialFolderOption.DoNotVerify), "Lidarr");
}
StartUpFolder = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
@ -47,4 +47,4 @@ namespace NzbDrone.Common.EnvironmentInfo
public string TempFolder { get; }
}
}
}

View file

@ -9,7 +9,8 @@ namespace NzbDrone.Common.EnvironmentInfo
public enum PlatformType
{
DotNet = 0,
Mono = 1
Mono = 1,
NetCore = 2
}
public interface IPlatformInfo
@ -26,6 +27,10 @@ namespace NzbDrone.Common.EnvironmentInfo
static PlatformInfo()
{
#if NETCOREAPP3_0
_platform = PlatformType.NetCore;
_version = new Version("3.0");
#else
if (Type.GetType("Mono.Runtime") != null)
{
_platform = PlatformType.Mono;
@ -36,11 +41,13 @@ namespace NzbDrone.Common.EnvironmentInfo
_platform = PlatformType.DotNet;
_version = GetDotNetVersion();
}
#endif
}
public static PlatformType Platform => _platform;
public static bool IsMono => Platform == PlatformType.Mono;
public static bool IsDotNet => Platform == PlatformType.DotNet;
public static bool IsNetCore => Platform == PlatformType.NetCore;
public static string PlatformName
{
@ -50,8 +57,14 @@ namespace NzbDrone.Common.EnvironmentInfo
{
return ".NET";
}
return "Mono";
else if (IsMono)
{
return "Mono";
}
else
{
return ".NET Core";
}
}
}

View file

@ -7,6 +7,10 @@ using System.ServiceProcess;
using NLog;
using NzbDrone.Common.Processes;
#if NETCOREAPP3_0
using Microsoft.Extensions.Hosting.WindowsServices;
#endif
namespace NzbDrone.Common.EnvironmentInfo
{
public class RuntimeInfo : IRuntimeInfo
@ -57,7 +61,12 @@ namespace NzbDrone.Common.EnvironmentInfo
}
}
#if !NETCOREAPP3_0
public static bool IsUserInteractive => Environment.UserInteractive;
#else
// Note that Environment.UserInteractive is always true on net core: https://stackoverflow.com/a/57325783
public static bool IsUserInteractive => OsInfo.IsWindows && !WindowsServiceHelpers.IsWindowsService();
#endif
bool IRuntimeInfo.IsUserInteractive => IsUserInteractive;
@ -65,6 +74,11 @@ namespace NzbDrone.Common.EnvironmentInfo
{
get
{
if (OsInfo.IsNotWindows)
{
return false;
}
try
{
var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());

View file

@ -0,0 +1,29 @@
using System;
namespace NzbDrone.Common.Exceptions
{
public class ServiceProviderException : NzbDroneException
{
public ServiceProviderException(string message, params object[] args)
: base(string.Format(message, args))
{
}
public ServiceProviderException(string message)
: base(message)
{
}
public ServiceProviderException(Exception innerException, string message, params object[] args)
: base(string.Format(message, args), innerException)
{
}
public ServiceProviderException(Exception innerException, string message)
: base(message, innerException)
{
}
}
}

View file

@ -6,11 +6,13 @@ namespace NzbDrone.Common.Extensions
{
public static class DictionaryExtensions
{
public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue = default(TValue))
#if !NETCOREAPP3_0
public static TValue GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue = default(TValue))
{
TValue value;
return dictionary.TryGetValue(key, out value) ? value : defaultValue;
}
#endif
public static Dictionary<T1, T2> Merge<T1, T2>(this Dictionary<T1, T2> first, Dictionary<T1, T2> second)
{

View file

@ -0,0 +1,30 @@
using System.IO;
using System.IO.Compression;
namespace NzbDrone.Common.Extensions
{
public static class GzipExtensions
{
public static byte[] Decompress(this byte[] data)
{
using (var compressedStream = new MemoryStream(data))
using (var gzip = new GZipStream(compressedStream, CompressionMode.Decompress))
using (var decompressedStream = new MemoryStream())
{
gzip.CopyTo(decompressedStream);
return decompressedStream.ToArray();
}
}
public static byte[] Compress(this byte[] data)
{
using (var compressedStream = new MemoryStream())
using (var zipStream = new GZipStream(compressedStream, CompressionMode.Compress))
{
zipStream.Write(data, 0, data.Length);
zipStream.Close();
return compressedStream.ToArray();
}
}
}
}

View file

@ -217,12 +217,9 @@ namespace NzbDrone.Common.Extensions
return null;
}
public static string ProcessNameToExe(this string processName, Version version)
public static string ProcessNameToExe(this string processName, PlatformType runtime)
{
// Windows always has exe (but is shunted to net core)
// Linux is kept on mono pending manual upgrade to net core so has .exe
// macOS is shunted to net core and does not have .exe
if (OsInfo.IsWindows || OsInfo.IsLinux || (version.Major == 0 && version.Minor == 7))
if (OsInfo.IsWindows || runtime != PlatformType.NetCore)
{
processName += ".exe";
}
@ -230,6 +227,11 @@ namespace NzbDrone.Common.Extensions
return processName;
}
public static string ProcessNameToExe(this string processName)
{
return processName.ProcessNameToExe(PlatformInfo.Platform);
}
public static string GetAppDataPath(this IAppFolderInfo appFolderInfo)
{
return appFolderInfo.AppDataFolder;
@ -290,9 +292,9 @@ namespace NzbDrone.Common.Extensions
return Path.Combine(GetUpdatePackageFolder(appFolderInfo), UPDATE_CLIENT_FOLDER_NAME);
}
public static string GetUpdateClientExePath(this IAppFolderInfo appFolderInfo, Version version)
public static string GetUpdateClientExePath(this IAppFolderInfo appFolderInfo, PlatformType runtime)
{
return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_CLIENT_EXE_NAME).ProcessNameToExe(version);
return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_CLIENT_EXE_NAME).ProcessNameToExe(runtime);
}
public static string GetDatabase(this IAppFolderInfo appFolderInfo)

View file

@ -1,6 +1,5 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Reflection;
using NLog;
@ -125,14 +124,7 @@ namespace NzbDrone.Common.Http.Dispatchers
if (PlatformInfo.IsMono && httpWebResponse.ContentEncoding == "gzip")
{
using (var compressedStream = new MemoryStream(data))
using (var gzip = new GZipStream(compressedStream, CompressionMode.Decompress))
using (var decompressedStream = new MemoryStream())
{
gzip.CopyTo(decompressedStream);
data = decompressedStream.ToArray();
}
data = data.Decompress();
httpWebResponse.Headers.Remove("Content-Encoding");
}
}

View file

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNet4.SocksProxy" Version="1.4.0.1" />
@ -8,12 +8,18 @@
<PackageReference Include="NLog" Version="4.6.7" />
<PackageReference Include="Sentry" Version="1.2.0" />
<PackageReference Include="SharpZipLib" Version="1.2.0" />
<PackageReference Include="System.IO.Abstractions" Version="4.0.11" />
<PackageReference Include="System.IO.Abstractions" Version="6.0.38" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="System.Data.SQLite.Core.Lidarr" Version="1.0.111.0-5" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Configuration.Install" />
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.6.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.6.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="3.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.6.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.ServiceProcess" />
</ItemGroup>
<ItemGroup>

View file

@ -1,10 +1,9 @@
using System;
using System.Collections.Specialized;
using System.Configuration.Install;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using NLog;
using NzbDrone.Common.Exceptions;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Processes;
@ -62,30 +61,36 @@ namespace NzbDrone.Common
public virtual void Install(string serviceName)
{
_logger.Info("Installing service '{0}'", serviceName);
var args = $"create {serviceName} " +
$"DisplayName= \"{serviceName}\" " +
$"binpath= \"{Process.GetCurrentProcess().MainModule.FileName}\" " +
"start= auto " +
"depend= EventLog/Tcpip/http " +
"obj= \"NT AUTHORITY\\LocalService\"";
var installer = new ServiceProcessInstaller
{
Account = ServiceAccount.LocalService
};
_logger.Info(args);
var serviceInstaller = new ServiceInstaller();
var installOutput = _processProvider.StartAndCapture("sc.exe", args);
if (installOutput.ExitCode != 0)
{
_logger.Error($"Failed to install service: {installOutput.Lines.Select(x => x.Content).ConcatToString("\n")}");
throw new ServiceProviderException("Failed to install service");
}
string[] cmdline = { @"/assemblypath=" + Process.GetCurrentProcess().MainModule.FileName };
_logger.Info(installOutput.Lines.Select(x => x.Content).ConcatToString("\n"));
var context = new InstallContext("service_install.log", cmdline);
serviceInstaller.Context = context;
serviceInstaller.DisplayName = serviceName;
serviceInstaller.ServiceName = serviceName;
serviceInstaller.Description = "Lidarr Application Server";
serviceInstaller.StartType = ServiceStartMode.Automatic;
serviceInstaller.ServicesDependedOn = new[] { "EventLog", "Tcpip", "http" };
var descOutput = _processProvider.StartAndCapture("sc.exe", $"description {serviceName} \"Lidarr Application Server\"");
if (descOutput.ExitCode != 0)
{
_logger.Error($"Failed to install service: {descOutput.Lines.Select(x => x.Content).ConcatToString("\n")}");
throw new ServiceProviderException("Failed to install service");
}
serviceInstaller.Parent = installer;
serviceInstaller.Install(new ListDictionary());
_logger.Info(descOutput.Lines.Select(x => x.Content).ConcatToString("\n"));
_logger.Info("Service Has installed successfully.");
}
@ -96,12 +101,8 @@ namespace NzbDrone.Common
Stop(serviceName);
var serviceInstaller = new ServiceInstaller();
var context = new InstallContext("service_uninstall.log", null);
serviceInstaller.Context = context;
serviceInstaller.ServiceName = serviceName;
serviceInstaller.Uninstall(null);
var output = _processProvider.StartAndCapture("sc.exe", $"delete {serviceName}");
_logger.Info(output.Lines.Select(x => x.Content).ConcatToString("\n"));
_logger.Info("{0} successfully uninstalled", serviceName);
}

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
<ApplicationIcon>..\NzbDrone.Host\NzbDrone.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>

View file

@ -163,7 +163,7 @@ namespace NzbDrone.Core.Test.Download
Mocker.GetMock<IIndexerStatusService>()
.Verify(v => v.RecordFailure(It.IsAny<int>(),
It.IsInRange<TimeSpan>(TimeSpan.FromMinutes(4.9), TimeSpan.FromMinutes(5.1), Range.Inclusive)), Times.Once());
It.IsInRange<TimeSpan>(TimeSpan.FromMinutes(4.9), TimeSpan.FromMinutes(5.1), Moq.Range.Inclusive)), Times.Once());
}
[Test]

File diff suppressed because one or more lines are too long

View file

@ -1,69 +0,0 @@
using System;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HealthCheck.Checks
{
[TestFixture]
public class DotnetVersionCheckFixture : CoreTest<DotnetVersionCheck>
{
private void GivenOutput(string version)
{
WindowsOnly();
Mocker.GetMock<IPlatformInfo>()
.SetupGet(s => s.Version)
.Returns(new Version(version));
}
[TestCase("4.7.2")]
[TestCase("4.8")]
public void should_return_ok(string version)
{
GivenOutput(version);
Subject.Check().ShouldBeOk();
}
[TestCase("4.6.2")]
[TestCase("4.7")]
[TestCase("4.7.1")]
public void should_return_notice(string version)
{
GivenOutput(version);
Subject.Check().ShouldBeNotice();
}
public void should_return_warning(string version)
{
GivenOutput(version);
Subject.Check().ShouldBeWarning();
}
[TestCase("4.5")]
[TestCase("4.5.2")]
[TestCase("4.6.1")]
public void should_return_error(string version)
{
GivenOutput(version);
Subject.Check().ShouldBeError();
}
[Test]
public void should_return_ok_for_net462_on_Win1511()
{
Mocker.GetMock<IOsInfo>()
.SetupGet(v => v.Version)
.Returns("10.0.14392");
GivenOutput("4.6.2");
Subject.Check().ShouldBeOk();
}
}
}

View file

@ -1,12 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.41" />
<PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="NBuilder" Version="6.0.1" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="4.0.11" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="6.0.38" />
<PackageReference Include="AutoFixture" Version="4.11.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="coverlet.collector" Version="1.1.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Test.Common\Lidarr.Test.Common.csproj" />
<ProjectReference Include="..\NzbDrone.Core\Lidarr.Core.csproj" />

View file

@ -3,11 +3,12 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using FluentAssertions;
using Moq;
using Newtonsoft.Json;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
@ -22,7 +23,7 @@ namespace NzbDrone.Core.Test.ParserTests
{
public class FingerPrintTest
{
public string RequestContent { get; set; }
public string Request { get; set; }
public string Response { get; set; }
}
@ -30,7 +31,7 @@ namespace NzbDrone.Core.Test.ParserTests
public void UseAcoustidResponses()
{
// responses were generated by editing HttpClient to write out the content bytes as a string
// using BitConverter.ToString(request.ContentData)
// using System.Text.Encoding.UTF8.GetString(request.ContentData.Decompress());
var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Fingerprinting", "AcoustidResponses.json");
var responses = JsonConvert.DeserializeObject<List<FingerPrintTest>>(File.ReadAllText(path));
@ -38,16 +39,13 @@ namespace NzbDrone.Core.Test.ParserTests
{
Mocker.GetMock<IHttpClient>()
.Setup(o => o.Post<LookupResponse>(
It.Is<HttpRequest>(v =>
v.Url.Equals(new HttpUri("https://api.acoustid.org/v2/lookup")) &&
v.Headers.Contains(new KeyValuePair<string, string>("Content-Encoding", "gzip")) &&
v.Headers.ContentType == "application/x-www-form-urlencoded" &&
// Skip past the first bit of gzip header which varies by OS:
// http://www.onicos.com/staff/iz/formats/gzip.html
BitConverter.ToString(v.ContentData).Substring(31) == response.RequestContent.Substring(31)
)))
It.Is<HttpRequest>(v =>
v.Url.Equals(new HttpUri("https://api.acoustid.org/v2/lookup")) &&
v.Headers.Contains(new KeyValuePair<string, string>("Content-Encoding", "gzip")) &&
v.Headers.ContentType == "application/x-www-form-urlencoded" &&
Encoding.UTF8.GetString(v.ContentData.Decompress()) == response.Request
)))
.Returns<HttpRequest>(r => new HttpResponse<LookupResponse>(new HttpResponse(r, new HttpHeader(), response.Response)));
}
}

View file

@ -25,6 +25,7 @@ namespace NzbDrone.Core.Test.UpdateTests
}
[Test]
[Platform(Exclude="NetCore")]
public void finds_update_when_version_lower()
{
UseRealHttp();

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore;

View file

@ -3,7 +3,6 @@ using System.Linq;
using System.Collections.Generic;
using NzbDrone.Common.Disk;
using NzbDrone.Common.Http;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Configuration;
@ -12,6 +11,7 @@ using NLog;
using FluentValidation.Results;
using System.Net;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.Download.Clients.Deluge
{

View file

@ -12,7 +12,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
{
HadoukenSystemInfo GetSystemInfo(HadoukenSettings settings);
HadoukenTorrent[] GetTorrents(HadoukenSettings settings);
IDictionary<string, object> GetConfig(HadoukenSettings settings);
IReadOnlyDictionary<string, object> GetConfig(HadoukenSettings settings);
string AddTorrentFile(HadoukenSettings settings, byte[] fileContent);
void AddTorrentUri(HadoukenSettings settings, string torrentUrl);
void RemoveTorrent(HadoukenSettings settings, string downloadId);
@ -42,9 +42,9 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
return GetTorrents(result.Torrents);
}
public IDictionary<string, object> GetConfig(HadoukenSettings settings)
public IReadOnlyDictionary<string, object> GetConfig(HadoukenSettings settings)
{
return ProcessRequest<IDictionary<string, object>>(settings, "webui.getSettings");
return ProcessRequest<IReadOnlyDictionary<string, object>>(settings, "webui.getSettings");
}
public string AddTorrentFile(HadoukenSettings settings, byte[] fileContent)

View file

@ -1,16 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Memory" Version="4.5.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0" />
<PackageReference Include="FluentMigrator.Runner" Version="4.0.0-alpha.268" />
<PackageReference Include="FluentMigrator.Runner.SQLite" Version="4.0.0-alpha.268" />
<PackageReference Include="FluentValidation" Version="8.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="NLog" Version="4.6.7" />
<PackageReference Include="RestSharp" Version="106.6.10" />
<PackageReference Include="System.IO.Abstractions" Version="4.0.11" />
<PackageReference Include="System.IO.Abstractions" Version="6.0.38" />
<PackageReference Include="TagLibSharp-Lidarr" Version="2.2.0.19" />
<PackageReference Include="Kveer.XmlRPC" Version="1.1.1" />
<PackageReference Include="SpotifyAPI.Web" Version="4.2.0" />
@ -22,7 +24,7 @@
<ProjectReference Include="..\MonoTorrent\MonoTorrent.csproj" />
<ProjectReference Include="..\NzbDrone.Common\Lidarr.Common.csproj" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
</ItemGroup>

View file

@ -6,8 +6,8 @@ using System.Linq;
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.EnsureThat;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Profiles.Releases;
using NzbDrone.Core.Qualities;

View file

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
@ -318,17 +317,6 @@ namespace NzbDrone.Core.Parser
return null;
}
private static byte[] Compress(byte[] data)
{
using (var compressedStream = new MemoryStream())
using (var zipStream = new GZipStream(compressedStream, CompressionMode.Compress))
{
zipStream.Write(data, 0, data.Length);
zipStream.Close();
return compressedStream.ToArray();
}
}
public void Lookup(List<LocalTrack> tracks, double threshold)
{
if (!IsSetup())
@ -365,7 +353,7 @@ namespace NzbDrone.Core.Parser
}
// they prefer a gzipped body
httpRequest.SetContent(Compress(Encoding.UTF8.GetBytes(sb.ToString())));
httpRequest.SetContent(Encoding.UTF8.GetBytes(sb.ToString()).Compress());
httpRequest.Headers.Add("Content-Encoding", "gzip");
httpRequest.Headers.ContentType = "application/x-www-form-urlencoded";
httpRequest.SuppressHttpError = true;

View file

@ -132,6 +132,7 @@ namespace NzbDrone.Core.Update
_diskTransferService.TransferFolder(_appFolderInfo.GetUpdateClientFolder(), updateSandboxFolder, TransferMode.Move, false);
// Set executable flag on update app
<<<<<<< HEAD
if (OsInfo.IsOsx)
{
_diskProvider.SetPermissions(_appFolderInfo.GetUpdateClientExePath(updatePackage.Version), "0755", null, null);
@ -141,6 +142,17 @@ namespace NzbDrone.Core.Update
_logger.ProgressInfo("Lidarr will restart shortly.");
_processProvider.Start(_appFolderInfo.GetUpdateClientExePath(updatePackage.Version), GetUpdaterArgs(updateSandboxFolder));
=======
if (OsInfo.IsOsx || (OsInfo.IsLinux && PlatformInfo.IsNetCore))
{
_diskProvider.SetPermissions(_appFolderInfo.GetUpdateClientExePath(updatePackage.Runtime), "0755", null, null);
}
_logger.Info("Starting update client {0}", _appFolderInfo.GetUpdateClientExePath(updatePackage.Runtime));
_logger.ProgressInfo("Lidarr will restart shortly.");
_processProvider.Start(_appFolderInfo.GetUpdateClientExePath(updatePackage.Runtime), GetUpdaterArgs(updateSandboxFolder));
>>>>>>> 4346c76d4... New: Multi target net framework 4.6.2 and net core 3.0
}
private void EnsureValidBranch(UpdatePackage package)

View file

@ -1,5 +1,5 @@
using System;
using NzbDrone.Common.EnvironmentInfo;
namespace NzbDrone.Core.Update
{
@ -12,5 +12,6 @@ namespace NzbDrone.Core.Update
public UpdateChanges Changes { get; set; }
public string Hash { get; set; }
public string Branch { get; set; }
public PlatformType Runtime { get; set; }
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using NzbDrone.Common.Cloud;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Http;
@ -34,6 +35,8 @@ namespace NzbDrone.Core.Update
.Resource("/update/{branch}")
.AddQueryParam("version", currentVersion)
.AddQueryParam("os", OsInfo.Os.ToString().ToLowerInvariant())
.AddQueryParam("arch", RuntimeInformation.OSArchitecture)
.AddQueryParam("runtime", PlatformInfo.Platform.ToString().ToLowerInvariant())
.AddQueryParam("runtimeVer", _platformInfo.Version)
.SetSegment("branch", branch);
@ -70,4 +73,4 @@ namespace NzbDrone.Core.Update
return updates.Resource;
}
}
}
}

View file

@ -1,12 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.41" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="coverlet.collector" Version="1.1.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Host\Lidarr.Host.csproj" />
<ProjectReference Include="..\NzbDrone.Test.Common\Lidarr.Test.Common.csproj" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.ServiceProcess" />
</ItemGroup>
</Project>

View file

@ -1,13 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Security.Cryptography.Cng" Version="4.6.0" />
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="2.2.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NLog.Extensions.Logging" Version="1.5.3" />
</ItemGroup>
<ItemGroup>

View file

@ -15,6 +15,7 @@ namespace NzbDrone.Host.Middleware
private readonly IContainer _container;
private readonly Logger _logger;
private static string API_KEY;
private static string URL_BASE;
public int Order => 1;
public SignalRMiddleware(IContainer container,
@ -24,6 +25,7 @@ namespace NzbDrone.Host.Middleware
_container = container;
_logger = logger;
API_KEY = configFileProvider.ApiKey;
URL_BASE = configFileProvider.UrlBase;
}
public void Attach(IApplicationBuilder appBuilder)
@ -53,11 +55,17 @@ namespace NzbDrone.Host.Middleware
}
});
appBuilder.UseSignalR(routes =>
#if NETCOREAPP3_0
appBuilder.UseEndpoints(x =>
{
routes.MapHub<MessageHub>("/signalr/messages");
x.MapHub<MessageHub>(URL_BASE + "/signalr/messages");
});
#else
appBuilder.UseSignalR(x =>
{
x.MapHub<MessageHub>("/signalr/messages");
});
#endif
// This is a side effect of haing multiple IoC containers, TinyIoC and whatever
// Kestrel/SignalR is using. Ideally we'd have one IoC container, but that's non-trivial with TinyIoC
// TODO: Use a single IoC container if supported for TinyIoC or if we switch to another system (ie Autofac).

View file

@ -5,7 +5,6 @@ using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog;
@ -77,6 +76,10 @@ namespace NzbDrone.Host
});
}
})
.ConfigureKestrel(serverOptions =>
{
serverOptions.AllowSynchronousIO = true;
})
.ConfigureLogging(logging =>
{
logging.AddProvider(new NLogLoggerProvider());
@ -86,15 +89,23 @@ namespace NzbDrone.Host
{
services
.AddSignalR()
.AddJsonProtocol(options =>
#if !NETCOREAPP3_0
.AddJsonProtocol(
#else
.AddNewtonsoftJsonProtocol(
#endif
options =>
{
options.PayloadSerializerSettings = Json.GetSerializerSettings();
});
})
.Configure(app =>
{
app.UsePathBase(_configFileProvider.UrlBase);
#if NETCOREAPP3_0
app.UseRouting();
#endif
app.Properties["host.AppName"] = BuildInfo.AppName;
app.UsePathBase(_configFileProvider.UrlBase);
foreach (var middleWare in _middlewares.OrderBy(c => c.Order))
{

View file

@ -8,6 +8,7 @@ using NzbDrone.Common.Disk;
using System.Reflection;
using System.IO;
using System.Collections.Generic;
using NzbDrone.Common;
namespace NzbDrone.Integration.Test.ApiTests
{
@ -61,7 +62,7 @@ namespace NzbDrone.Integration.Test.ApiTests
result.Directories.Should().NotBeNullOrEmpty();
result.Files.Should().NotBeNullOrEmpty();
result.Files.Should().Contain(v => v.Path == _file && v.Type == FileSystemEntityType.File);
result.Files.Should().Contain(v => PathEqualityComparer.Instance.Equals(v.Path, _file) && v.Type == FileSystemEntityType.File);
}
[Test]

View file

@ -15,6 +15,7 @@ namespace NzbDrone.Integration.Test.ApiTests
}
[Test]
[Ignore("SignalR on CI seems unstable")]
public void should_add_and_delete_root_folders()
{
ConnectSignalR().Wait();

View file

@ -1,10 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.41" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="1.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lidarr.Api.V1\Lidarr.Api.V1.csproj" />
<ProjectReference Include="..\NzbDrone.Test.Common\Lidarr.Test.Common.csproj" />

View file

@ -1,7 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.41" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="coverlet.collector" Version="1.1.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Test.Common\Lidarr.Test.Common.csproj" />
</ItemGroup>

View file

@ -1,17 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.41" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Mono.Posix-4.5" Version="4.5.0" PrivateAssets="all"/>
</ItemGroup>
<!--
The netstandard veresion here doesn't work in net framework
See https://github.com/xamarin/XamarinComponents/issues/282
-->
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
<PackageReference Include="coverlet.collector" Version="1.1.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Common.Test\Lidarr.Common.Test.csproj" />
<ProjectReference Include="..\NzbDrone.Test.Common\Lidarr.Test.Common.csproj" />
<ProjectReference Include="..\NzbDrone.Mono\Lidarr.Mono.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Mono.Posix">
<HintPath>..\Libraries\Mono.Posix.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Update="Files\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

View file

@ -1,17 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="4.6.7" />
<PackageReference Include="System.IO.Abstractions" Version="4.0.11" />
<PackageReference Include="System.IO.Abstractions" Version="6.0.38" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Mono.Posix-4.5" Version="4.5.0" PrivateAssets="all"/>
</ItemGroup>
<!--
The netstandard veresion here doesn't work in net framework
See https://github.com/xamarin/XamarinComponents/issues/282
-->
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Common\Lidarr.Common.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Mono.Posix">
<HintPath>..\Libraries\Mono.Posix.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View file

@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>

View file

@ -9,6 +9,7 @@ using System.Runtime.CompilerServices;
using Unity;
using Moq;
using Moq.Language.Flow;
using NzbDrone.Common.Composition;
using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Test.Common.AutoMoq.Unity;
@ -150,6 +151,10 @@ namespace NzbDrone.Test.Common.AutoMoq
RegisterPlatformLibrary(container);
AddTheAutoMockingContainerExtensionToTheContainer(container);
#if NETCOREAPP3_0
ContainerBuilderBase.RegisterSQLiteResolver();
#endif
}
private static void AddTheAutoMockingContainerExtensionToTheContainer(IUnityContainer container)

View file

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.9.0" />
@ -10,7 +10,7 @@
<PackageReference Include="NLog" Version="4.6.7" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="RestSharp" Version="106.6.10" />
<PackageReference Include="System.IO.Abstractions" Version="4.0.11" />
<PackageReference Include="System.IO.Abstractions" Version="6.0.38" />
<PackageReference Include="Unity" Version="5.11.1" />
</ItemGroup>
<ItemGroup>

View file

@ -33,17 +33,29 @@ namespace NzbDrone.Test.Common
Directory.CreateDirectory(AppData);
GenerateConfigFile();
var lidarrConsoleExe = OsInfo.IsWindows ? "Lidarr.Console.exe" : "Lidarr.exe";
var frameworkFolder = "net462";
string lidarrConsoleExe;
if (OsInfo.IsWindows)
{
lidarrConsoleExe = "Lidarr.Console.exe";
}
else if (PlatformInfo.IsMono)
{
lidarrConsoleExe = "Lidarr.exe";
}
else
{
lidarrConsoleExe = "Lidarr";
}
if (BuildInfo.IsDebug)
{
var frameworkFolder = PlatformInfo.IsNetCore ? "netcoreapp3.0" : "net462";
Start(Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "..", "_output", frameworkFolder, lidarrConsoleExe));
}
else
{
Start(Path.Combine("bin", lidarrConsoleExe));
Start(Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "bin", lidarrConsoleExe));
}
while (true)

View file

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
</Project>

View file

@ -1,7 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.41" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="coverlet.collector" Version="1.1.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Test.Common\Lidarr.Test.Common.csproj" />
<ProjectReference Include="..\NzbDrone.Update\Lidarr.Update.csproj" />

View file

@ -3,6 +3,7 @@ using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Processes;
using NzbDrone.Test.Common;
using NzbDrone.Update.UpdateEngine;
@ -27,7 +28,7 @@ namespace NzbDrone.Update.Test
public void should_start_console_if_app_type_was_service_but_start_failed_because_of_permissions()
{
string targetFolder = "c:\\Lidarr\\".AsOsAgnostic();
string targetProcess = "c:\\Lidarr\\Lidarr.Console.exe".AsOsAgnostic();
string targetProcess = "c:\\Lidarr\\Lidarr.Console".AsOsAgnostic().ProcessNameToExe();
Mocker.GetMock<IServiceProvider>().Setup(c => c.Start(ServiceProvider.SERVICE_NAME)).Throws(new InvalidOperationException());

View file

@ -1,241 +0,0 @@
/*
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Common.Model;
using NzbDrone.Test.Common;
using NzbDrone.Update.UpdateEngine;
namespace NzbDrone.Update.Test
{
[TestFixture]
public class UpdateProviderStartFixture : TestBase
{
private const string UPDATE_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone\";
private const string BACKUP_FOLDER = @"C:\Temp\nzbdrone_update\nzbdrone_backup\";
private const string TARGET_FOLDER = @"C:\NzbDrone\";
Mock<IIAppDirectoryInfo> _IAppDirectoryInfo;
[SetUp]
public void Setup()
{
_IAppDirectoryInfo = Mocker.GetMock<IIAppDirectoryInfo>();
_IAppDirectoryInfo.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.FolderExists(UPDATE_FOLDER))
.Returns(true);
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.FolderExists(TARGET_FOLDER))
.Returns(true);
}
private void WithInstalledService()
{
Mocker.GetMock<IServiceProvider>()
.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
.Returns(true);
}
private void WithServiceRunning(bool state)
{
Mocker.GetMock<IServiceProvider>()
.Setup(c => c.IsServiceRunning(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(state);
}
[Test]
public void should_stop_nzbdrone_service_if_installed_and_running()
{
WithInstalledService();
WithServiceRunning(true);
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
Mocker.GetMock<IServiceProvider>().Verify(c => c.Stop(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
}
[Test]
public void should_not_stop_nzbdrone_service_if_installed_but_not_running()
{
WithInstalledService();
WithServiceRunning(false);
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
Mocker.GetMock<IServiceProvider>().Verify(c => c.Stop(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Never());
}
[Test]
public void should_not_stop_nzbdrone_service_if_service_isnt_installed()
{
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
Mocker.GetMock<IServiceProvider>().Verify(c => c.Stop(It.IsAny<string>()), Times.Never());
}
[Test]
public void should_kill_nzbdrone_process_if_running()
{
var proccesses = Builder<ProcessInfo>.CreateListOfSize(2).Build().ToList();
Mocker.GetMock<IProcessProvider>()
.Setup(c => c.GetProcessByName(ProcessProvider.NzbDroneProcessName))
.Returns(proccesses);
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
Mocker.GetMock<IProcessProvider>().Verify(c => c.KillAll(ProcessProvider.NzbDroneProcessName), Times.Once());
}
[Test]
public void should_not_kill_nzbdrone_process_not_running()
{
Mocker.GetMock<IProcessProvider>()
.Setup(c => c.GetProcessByName(ProcessProvider.NzbDroneProcessName))
.Returns(new List<ProcessInfo>());
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
Mocker.GetMock<IProcessProvider>().Verify(c => c.Kill(It.IsAny<int>()), Times.Never());
}
[Test]
public void should_create_backup_of_current_installation()
{
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.CopyDirectory(TARGET_FOLDER, BACKUP_FOLDER));
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
}
[Test]
public void should_copy_update_package_to_target()
{
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.CopyDirectory(UPDATE_FOLDER, TARGET_FOLDER));
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.DeleteFolder(UPDATE_FOLDER, true));
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
}
[Test]
public void should_restore_if_update_fails()
{
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.CopyDirectory(UPDATE_FOLDER, TARGET_FOLDER))
.Throws(new IOException());
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
Mocker.GetMock<IDiskProvider>()
.Verify(c => c.CopyDirectory(BACKUP_FOLDER, TARGET_FOLDER), Times.Once());
ExceptionVerification.ExpectedFatals(1);
}
[Test]
public void should_restart_service_if_service_was_running()
{
WithInstalledService();
WithServiceRunning(true);
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
VerifyServiceRestart();
}
[Test]
public void should_restart_process_if_service_was_not_running()
{
WithInstalledService();
WithServiceRunning(false);
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
VerifyProcessRestart();
}
[Test]
public void should_restart_service_if_service_was_running_and_update_fails()
{
WithInstalledService();
WithServiceRunning(true);
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.CopyDirectory(UPDATE_FOLDER, TARGET_FOLDER))
.Throws(new IOException());
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
VerifyServiceRestart();
ExceptionVerification.ExpectedFatals(1);
}
[Test]
public void should_restart_process_if_service_was_not_running_and_update_fails()
{
WithInstalledService();
WithServiceRunning(false);
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.CopyDirectory(UPDATE_FOLDER, TARGET_FOLDER))
.Throws(new IOException());
Mocker.Resolve<InstallUpdateService>().Start(TARGET_FOLDER);
VerifyProcessRestart();
ExceptionVerification.ExpectedFatals(1);
}
private void VerifyServiceRestart()
{
Mocker.GetMock<IServiceProvider>()
.Verify(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
Mocker.GetMock<IProcessProvider>()
.Verify(c => c.Start(It.IsAny<string>()), Times.Never());
}
private void VerifyProcessRestart()
{
Mocker.GetMock<IServiceProvider>()
.Verify(c => c.Start(It.IsAny<string>()), Times.Never());
Mocker.GetMock<IProcessProvider>()
.Verify(c => c.Start(TARGET_FOLDER + "NzbDrone.exe"), Times.Once());
}
}
}
*/

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="4.6.7" />

View file

@ -114,7 +114,7 @@ namespace NzbDrone.Update.UpdateEngine
_diskTransferService.MirrorFolder(_appFolderInfo.GetUpdatePackageFolder(), installationFolder);
// Set executable flag on Lidarr app
if (OsInfo.IsOsx)
if (OsInfo.IsOsx || (OsInfo.IsLinux && PlatformInfo.IsNetCore))
{
_diskProvider.SetPermissions(Path.Combine(installationFolder, "Lidarr"), "0755", null, null);
}

View file

@ -3,6 +3,7 @@ using System.IO;
using NLog;
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Processes;
using IServiceProvider = NzbDrone.Common.IServiceProvider;
@ -62,12 +63,12 @@ namespace NzbDrone.Update.UpdateEngine
private void StartWinform(string installationFolder)
{
Start(installationFolder, "Lidarr.exe");
Start(installationFolder, "Lidarr".ProcessNameToExe());
}
private void StartConsole(string installationFolder)
{
Start(installationFolder, "Lidarr.Console.exe");
Start(installationFolder, "Lidarr.Console".ProcessNameToExe());
}
private void Start(string installationFolder, string fileName)
@ -83,4 +84,4 @@ namespace NzbDrone.Update.UpdateEngine
_processProvider.SpawnNewProcess(path, _startupContext.PreservedArguments);
}
}
}
}

View file

@ -25,15 +25,17 @@ namespace NzbDrone.Windows.Test.DiskProviderTests
if (Directory.Exists(path))
{
var ds = Directory.GetAccessControl(path);
var directory = new DirectoryInfo(path);
var ds = directory.GetAccessControl();
ds.SetAccessRule(new FileSystemAccessRule(owner, FileSystemRights.Write, accessControlType));
Directory.SetAccessControl(path, ds);
directory.SetAccessControl(ds);
}
else
{
var fs = File.GetAccessControl(path);
var file = new FileInfo(path);
var fs = file.GetAccessControl();
fs.SetAccessRule(new FileSystemAccessRule(owner, FileSystemRights.Write, accessControlType));
File.SetAccessControl(path, fs);
file.SetAccessControl(fs);
}
}
}

View file

@ -6,7 +6,7 @@ using NzbDrone.Test.Common;
namespace NzbDrone.Windows.Test.EnvironmentInfo
{
[TestFixture]
[Platform("Win")]
[Platform("Net")]
public class DotNetPlatformInfoFixture : TestBase<PlatformInfo>
{
[Test]

View file

@ -1,7 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.41" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="coverlet.collector" Version="1.1.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Common.Test\Lidarr.Common.Test.csproj" />
<ProjectReference Include="..\NzbDrone.Test.Common\Lidarr.Test.Common.csproj" />

View file

@ -2,6 +2,7 @@
using System.IO;
using System.IO.Abstractions;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Common.EnsureThat;
@ -50,9 +51,10 @@ namespace NzbDrone.Windows.Disk
{
Ensure.That(filename, () => filename).IsValidPath();
var fs = File.GetAccessControl(filename);
var file = _fileSystem.FileInfo.FromFileName(filename);
var fs = file.GetAccessControl();
fs.SetAccessRuleProtection(false, false);
File.SetAccessControl(filename, fs);
file.SetAccessControl(fs);
}
public override void SetPermissions(string path, string mask, string user, string group)

View file

@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="4.6.7" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.6.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Common\Lidarr.Common.csproj" />

View file

@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net462</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>..\NzbDrone.Host\NzbDrone.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
@ -13,7 +14,7 @@
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Host\Lidarr.Host.csproj" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>

View file

@ -10,21 +10,22 @@
<Target Name="PublishAllRids">
<ItemGroup>
<!-- Transform RuntimeIdentifiers property to item -->
<Runtimes Include="$(RuntimeIdentifiers)" />
<Frameworks Include="$(TargetFrameworks)" />
<Combined1 Include="@(Runtimes)">
<Runtime>%(Runtimes.Identity)</Runtime>
</Combined1>
<Combined2 Include="@(Combined1)">
<Combined Include="$(RuntimeIdentifiers)">
<Framework>%(Frameworks.Identity)</Framework>
</Combined2>
</Combined>
<Renamed Include="@(Combined->'%(Identity):%(Framework)')">
<Runtime>%(Identity)</Runtime>
<Framework>%(Framework)</Framework>
</Renamed>
<Renamed Remove="$(ExcludedRuntimeFrameworkPairs)" />
<!-- Transform RuntimeIdentifierForPublish items to project items to pass to MSBuild task -->
<ProjectToPublish Include="@(Combined2->'$(MSBuildProjectFullPath)')">
<AdditionalProperties>RuntimeIdentifier=%(Combined2.Runtime);TargetFramework=%(Combined2.Framework)</AdditionalProperties>
<ProjectToPublish Include="@(Renamed->'$(MSBuildProjectFullPath)')">
<AdditionalProperties>RuntimeIdentifier=%(Renamed.Runtime);TargetFramework=%(Renamed.Framework)</AdditionalProperties>
</ProjectToPublish>
</ItemGroup>

View file

@ -1,6 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net462</TargetFrameworks>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="System.Security.Principal.Windows" Version="4.6.0" />
</ItemGroup>
</Project>

View file

@ -1,6 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net462</TargetFrameworks>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="System.Security.Principal.Windows" Version="4.6.0" />
</ItemGroup>
</Project>

21
src/coverlet.runsettings Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>opencover</Format>
<Exclude>[Lidarr.*.Test]*,[Lidarr.Test.*]*,[Lidarr.Api.V1]*,[Marr.Data]*,[MonoTorrent]*</Exclude>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<InProcDataCollectionRunSettings>
<InProcDataCollectors>
<InProcDataCollector assemblyQualifiedName="Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null"
friendlyName="XPlat Code Coverage"
enabled="True"
codebase="coverlet.collector.dll" />
</InProcDataCollectors>
</InProcDataCollectionRunSettings>
</RunSettings>