Update client is now included in the build package

pull/7/merge
kay.one 13 years ago
parent 53be0e374b
commit 56a6e1372d

@ -4,6 +4,7 @@ using System.Linq;
using System.Xml.Linq;
using System.Xml.XPath;
using NLog;
using Ninject;
using NzbDrone.Common.Model;
namespace NzbDrone.Common
@ -14,6 +15,8 @@ namespace NzbDrone.Common
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private readonly string _configFile;
[Inject]
public ConfigFileProvider(EnviromentProvider enviromentProvider)
{
_enviromentProvider = enviromentProvider;
@ -22,6 +25,11 @@ namespace NzbDrone.Common
CreateDefaultConfigFile();
}
public ConfigFileProvider()
{
}
public virtual Guid Guid
{
get

@ -68,7 +68,6 @@ namespace NzbDrone.Common
if (LogManager.ThrowExceptions)
throw;
}
}
public static void RegisterExceptioneer()

@ -30,11 +30,15 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Exceptioneer.WindowsFormsClient">
<HintPath>..\Libraries\Exceptioneer.WindowsFormsClient.dll</HintPath>
</Reference>
<Reference Include="Ninject">
<HintPath>..\packages\Ninject.2.2.1.4\lib\net40-Full\Ninject.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference>

@ -18,6 +18,8 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
{
private const string SANDBOX_FOLDER = @"C:\Temp\nzbdrone_update\";
private readonly Guid _clientGuid = Guid.NewGuid();
private readonly UpdatePackage updatePackage = new UpdatePackage
{
FileName = "NzbDrone.kay.one.0.6.0.2031.zip",
@ -29,6 +31,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
public void Setup()
{
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
Mocker.GetMock<ConfigFileProvider>().SetupGet(c => c.Guid).Returns(_clientGuid);
}
@ -65,15 +68,18 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
//Setup
var updateClientPath = Mocker.GetMock<EnviromentProvider>().Object.GetUpdateClientExePath();
Mocker.GetMock<EnviromentProvider>()
.SetupGet(c => c.NzbDroneProcessIdFromEnviroment).Returns(12);
//Act
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
//Assert
Mocker.GetMock<ProcessProvider>().Verify(
c => c.Start(It.Is<ProcessStartInfo>(p =>
c => c.Start(It.Is<ProcessStartInfo>(p =>
p.FileName == updateClientPath &&
p.Arguments == "/12 /"
)));
p.Arguments == "/12 /" + _clientGuid.ToString())
));
}
[Test]

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
@ -16,8 +17,10 @@ namespace NzbDrone.Core.Providers
{
private readonly HttpProvider _httpProvider;
private readonly ConfigProvider _configProvider;
private readonly ConfigFileProvider _configFileProvider;
private readonly EnviromentProvider _enviromentProvider;
private readonly ArchiveProvider _archiveProvider;
private readonly ProcessProvider _processProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private static readonly Regex parseRegex = new Regex(@"(?:\>)(?<filename>NzbDrone.+?(?<version>\d+\.\d+\.\d+\.\d+).+?)(?:\<\/A\>)", RegexOptions.IgnoreCase);
@ -25,13 +28,15 @@ namespace NzbDrone.Core.Providers
[Inject]
public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider,
EnviromentProvider enviromentProvider, ArchiveProvider archiveProvider)
public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider, ConfigFileProvider configFileProvider,
EnviromentProvider enviromentProvider, ArchiveProvider archiveProvider, ProcessProvider processProvider)
{
_httpProvider = httpProvider;
_configProvider = configProvider;
_configFileProvider = configFileProvider;
_enviromentProvider = enviromentProvider;
_archiveProvider = archiveProvider;
_processProvider = processProvider;
}
public UpdateProvider()
@ -82,6 +87,17 @@ namespace NzbDrone.Core.Providers
logger.Info("Extracting Update package");
_archiveProvider.ExtractArchive(packageDestination, _enviromentProvider.GetUpdateSandboxFolder());
logger.Info("Update package extracted successfully");
logger.Info("Starting update client");
var startInfo = new ProcessStartInfo()
{
FileName = _enviromentProvider.GetUpdateClientExePath(),
Arguments = string.Format("/{0} /{1}", _enviromentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid)
};
_processProvider.Start(startInfo);
}
}

@ -48,7 +48,9 @@
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL" />
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>

@ -11,7 +11,8 @@
<RootNamespace>NzbDrone.Update</RootNamespace>
<AssemblyName>NzbDrone.Update</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
@ -49,6 +50,7 @@
<Compile Include="Providers\UpdateProvider.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

@ -4,10 +4,12 @@ SET TARGET=%PACKAGEROOT%\NzbDrone
rd %TARGET% /S /Q
del nzbdrone*.zip /Q /F
xcopy IISExpress %TARGET%\IISExpress /E /V /I /Y
xcopy NzbDrone\bin\Release\*.* %TARGET%\ /E /V /I /Y
xcopy NzbDrone.Update\bin\Release\*.* %TARGET%\NzbDrone.Update\ /E /V /I /Y
xcopy NzbDrone.Web\bin\*.* %TARGET%\NzbDrone.Web\bin\ /E /V /I /Y
xcopy NzbDrone.Web\App_GlobalResources\*.* %TARGET%\NzbDrone.Web\App_GlobalResources\ /E /V /I /Y
@ -15,7 +17,8 @@ xcopy NzbDrone.Web\Content\*.* %TARGET%\NzbDrone.Web\Content\ /E /V /I /Y
xcopy NzbDrone.Web\Scripts\*.* %TARGET%\NzbDrone.Web\Scripts\ /E /V /I /Y
xcopy NzbDrone.Web\Views\*.* %TARGET%\NzbDrone.Web\Views\ /E /V /I /Y
del %TARGET%\NzbDrone.Web\bin\*.xml /q
del %TARGET%\NzbDrone.Web\bin\*.xml /Q /F
xcopy NzbDrone.Web\log.config %TARGET%\NzbDrone.Web\
@ -27,6 +30,8 @@ xcopy NzbDrone.Web\web.config %TARGET%\NzbDrone.Web\
CD %PACKAGEROOT%
del nlog.xml /Q /F /S
del nlog.pdb /Q /F /S
del Twitterizer2.pdb /Q /F /S
del *.vshost.exe.* /Q /F /S
del ninject*.pdb /Q /F /S
del ninject*.xml /Q /F /S

Loading…
Cancel
Save