Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Inceptum.AppServer.Hosting;
using Inceptum.AppServer.Model;
using Newtonsoft.Json;
using NuGet;
using OpenRasta.Web;

namespace Inceptum.AppServer.Management.Handlers
Expand Down Expand Up @@ -107,7 +108,7 @@ public void Restart(string instance)
}

[HttpOperation(HttpMethod.PUT, ForUriName = "version")]
public void Version(string instance, [JsonConverter(typeof(StringVersionJsonConverter))]Version version)
public void Version(string instance, [JsonConverter(typeof(StringVersionJsonConverter))]SemanticVersion version)
{
m_Host.SetInstanceVersion(instance, version);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,18 @@
<Reference Include="Microsoft.CompilerServices.AsyncTargetingPack.Net4">
<HintPath>..\packages\Microsoft.CompilerServices.AsyncTargetingPack.1.0.1\lib\net40\Microsoft.CompilerServices.AsyncTargetingPack.Net4.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.XmlTransform, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NuGet.Core, Version=2.8.50926.602, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.Core.2.8.3\lib\net40-Client\NuGet.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OpenRasta, Version=2.0.3.0, Culture=neutral, PublicKeyToken=e04bf464d7caae73, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\OpenRasta.dll</HintPath>
Expand Down
2 changes: 2 additions & 0 deletions src/Inceptum.AppServer.Management/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<package id="jQuery" version="1.6.4" targetFramework="net40" />
<package id="Microsoft.AspNet.SignalR.JS" version="1.1.2" targetFramework="net40" />
<package id="Microsoft.CompilerServices.AsyncTargetingPack" version="1.0.1" targetFramework="net40" requireReinstallation="True" />
<package id="Microsoft.Web.Xdt" version="2.1.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net40" requireReinstallation="True" />
<package id="NuGet.Core" version="2.8.3" targetFramework="net45" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net40" />
</packages>
5 changes: 3 additions & 2 deletions src/Inceptum.AppServer.Sdk/AppInfo.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
using System;
using NuGet;

namespace Inceptum.AppServer
{
[Serializable]
public class AppInfo
{
public AppInfo(string name, Version version)
public AppInfo(string name, SemanticVersion version)
{
Name = name;
Version = version;
}

public string Name { get; private set; }

public Version Version { get; private set; }
public SemanticVersion Version { get; private set; }

public static bool operator ==(AppInfo info1, AppInfo info2)
{
Expand Down
7 changes: 4 additions & 3 deletions src/Inceptum.AppServer.Sdk/HostedAppInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using NuGet;

namespace Inceptum.AppServer
{
Expand All @@ -12,7 +13,7 @@ public class HostedAppInfo
{


public HostedAppInfo(string name,string vendor, Version version,string appType, IDictionary<AssemblyName, string> assembliesToLoad, IEnumerable<string> nativeDllToLoad = null)
public HostedAppInfo(string name,string vendor, SemanticVersion version,string appType, IDictionary<AssemblyName, string> assembliesToLoad, IEnumerable<string> nativeDllToLoad = null)
{
AssembliesToLoad = new Dictionary<AssemblyName, string>(assembliesToLoad);
NativeDllToLoad = (nativeDllToLoad??new string[0]).ToArray();
Expand All @@ -23,7 +24,7 @@ public HostedAppInfo(string name,string vendor, Version version,string appType,
Vendor = vendor;
}

public HostedAppInfo(string name, string vendor, Version version)
public HostedAppInfo(string name, string vendor, SemanticVersion version)
{
Name = name;
Version = version;
Expand All @@ -37,7 +38,7 @@ public HostedAppInfo(string name, string vendor, Version version)
public string Description { get; set; }
public string AppType { get; set; }
public string[] ConfigFiles { get; set; }
public Version Version { get; set; }
public SemanticVersion Version { get; set; }

public string[] NativeDllToLoad { get; private set; }
public bool Debug { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/Inceptum.AppServer.Sdk/IHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Threading.Tasks;
using Inceptum.AppServer.Hosting;
using Inceptum.AppServer.Model;

using NuGet;

namespace Inceptum.AppServer
{
Expand All @@ -25,7 +25,7 @@ public interface IHost
void AddInstance(ApplicationInstanceInfo config);
void DeleteInstance(string name);
void UpdateInstance(ApplicationInstanceInfo config);
void SetInstanceVersion(string name, Version version);
void SetInstanceVersion(string name, SemanticVersion version);

Task StartInstance(string name, bool doDebug);
Task StopInstance(string name);
Expand Down
8 changes: 8 additions & 0 deletions src/Inceptum.AppServer.Sdk/Inceptum.AppServer.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Castle.Windsor.3.2.1\lib\net40\Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.XmlTransform, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
Expand All @@ -55,6 +59,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NLog.2.1.0\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="NuGet.Core, Version=2.8.50926.602, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.Core.2.8.3\lib\net40-Client\NuGet.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
Expand Down
5 changes: 3 additions & 2 deletions src/Inceptum.AppServer.Sdk/Model/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Configuration;
using System.Linq;
using Newtonsoft.Json;
using NuGet;

namespace Inceptum.AppServer.Model
{
Expand All @@ -14,7 +15,7 @@ public class Application : IComparer<ApplicationVersion>
public string Vendor { get; private set; }
public string Repository { get; private set; }

public Application(string repository,string id, string vendor, Dictionary<Version, string> versions)
public Application(string repository,string id, string vendor, Dictionary<SemanticVersion, string> versions)
{
Repository = repository;
Name = id;
Expand All @@ -38,7 +39,7 @@ public ApplicationVersion[] Versions

int IComparer<ApplicationVersion>.Compare(ApplicationVersion x, ApplicationVersion y)
{
return -1 * Comparer<Version>.Default.Compare(x.Version, y.Version);
return -1 * Comparer<SemanticVersion>.Default.Compare(x.Version, y.Version);
}

public override string ToString()
Expand Down
5 changes: 3 additions & 2 deletions src/Inceptum.AppServer.Sdk/Model/ApplicationInstanceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Inceptum.AppServer.Hosting;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using NuGet;

namespace Inceptum.AppServer.Model
{
Expand All @@ -15,7 +16,7 @@ public class ApplicationInstanceInfo
public string ApplicationVendor { get; set; }

[JsonConverter(typeof (StringVersionJsonConverter))]
public Version Version { get; set; }
public SemanticVersion Version { get; set; }

[JsonConverter(typeof (StringEnumConverter))]
public HostedAppStatus Status { get; set; }
Expand All @@ -25,7 +26,7 @@ public class ApplicationInstanceInfo
public bool IsDebuggable { get; set; }

[JsonConverter(typeof(StringVersionJsonConverter))]
public Version ActualVersion { get; set; }
public SemanticVersion ActualVersion { get; set; }

public string Environment { get; set; }

Expand Down
3 changes: 2 additions & 1 deletion src/Inceptum.AppServer.Sdk/Model/ApplicationVersion.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Newtonsoft.Json;
using NuGet;

namespace Inceptum.AppServer.Model
{
Expand All @@ -8,7 +9,7 @@ public class ApplicationVersion
public string Description { get; set; }

[JsonConverter(typeof(StringVersionJsonConverter))]
public Version Version { get; set; }
public SemanticVersion Version { get; set; }

[JsonIgnore]
public string Browser { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion src/Inceptum.AppServer.Sdk/Model/InstanceConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Castle.Core.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using NuGet;

namespace Inceptum.AppServer.Model
{
Expand All @@ -13,7 +14,7 @@ public class InstanceConfig
public string ApplicationId { get; set; }
public string ApplicationVendor { get; set; }
[JsonConverter(typeof(StringVersionJsonConverter))]
public Version Version { get; set; }
public SemanticVersion Version { get; set; }
public bool AutoStart { get; set; }

public string User
Expand Down
13 changes: 7 additions & 6 deletions src/Inceptum.AppServer.Sdk/StringVersionJsonConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Globalization;
using Newtonsoft.Json;
using NuGet;

namespace Inceptum.AppServer
{
Expand All @@ -14,30 +15,30 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
}
else
{
var version= (Version)value;
var version = (SemanticVersion)value;
writer.WriteValue(version.ToString());
}
}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
Version version=null;
SemanticVersion version = null;
if (reader.TokenType == JsonToken.String)
{
if (reader.Value == null || reader.Value.ToString() == string.Empty)
return null;
if(!Version.TryParse(reader.Value.ToString(),out version))
throw new Exception("Unexpected token when parsing version. Expected String in version format (\\d+.\\d+.\\d+.\\d+)");
if (!SemanticVersion.TryParse(reader.Value.ToString(), out version))
throw new Exception("Unexpected token when parsing version.");
}else if (reader.TokenType != JsonToken.Null)
{
throw new Exception("Unexpected token when parsing version. Expected String in version format (\\d+.\\d+.\\d+.\\d+)");
throw new Exception("Unexpected token when parsing version.");
}
return version;
}

public override bool CanConvert(Type objectType)
{
return objectType==typeof(Version);
return objectType == typeof(SemanticVersion);
}


Expand Down
2 changes: 2 additions & 0 deletions src/Inceptum.AppServer.Sdk/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<package id="Castle.Core" version="3.2.2" targetFramework="net40" requireReinstallation="True" />
<package id="Castle.Core-NLog" version="3.2.0" targetFramework="net40" />
<package id="Castle.Windsor" version="3.2.1" targetFramework="net40" requireReinstallation="True" />
<package id="Microsoft.Web.Xdt" version="2.1.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net40" requireReinstallation="True" />
<package id="NLog" version="2.1.0" targetFramework="net40" requireReinstallation="True" />
<package id="NuGet.Core" version="2.8.3" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
using System.IO;
using System.Linq;
using System.Reflection;
using Castle.Core.Logging;
using NuGet;
using ILogger = Castle.Core.Logging.ILogger;

namespace Inceptum.AppServer.AppDiscovery
{
Expand Down Expand Up @@ -44,7 +45,7 @@ private Tuple<ApplicationInfo,string> getApplication(string folder)
let vendor = vendorAttribute == null ? null : vendorAttribute.ConstructorArguments[0].Value.ToString()
let types = asm.MainModule.Types.Where(t => t.Interfaces.Any(i => i.FullName == typeof (IHostedApplication).FullName)).Select(t => t.FullName + ", " + asm.FullName)
where types.Any()
select Tuple.Create(new ApplicationInfo {Debug=true,ApplicationId = applicationId, Vendor = vendor, Version = asm.Name.Version},file.path)).ToArray();
select Tuple.Create(new ApplicationInfo {Debug=true,ApplicationId = applicationId, Vendor = vendor, Version = new SemanticVersion(asm.Name.Version)}, file.path)).ToArray();



Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using NuGet;

namespace Inceptum.AppServer.AppDiscovery
{
Expand All @@ -9,7 +10,7 @@ public class ApplicationInfo
public string Vendor { get; set; }
public string Description { get; set; }
public string ApplicationId { get; set; }
public Version Version { get; set; }
public SemanticVersion Version { get; set; }

protected bool Equals(ApplicationInfo other)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public IEnumerable<ApplicationInfo> GetAvailableApps()
{
ApplicationId = package.Id,
Vendor = string.Join(", ", package.Authors),
Version = package.Version.Version,
Version = package.Version,
Description = package.Description
});
}
Expand All @@ -63,14 +63,14 @@ public void Install(string path, ApplicationInfo application)
{

string installPath = path;
Version installedVersion=null;
SemanticVersion installedVersion=null;
var versionFile = Path.Combine(installPath, "version");
var projectManager = new ProjectManagerWrapper(application.ApplicationId,m_LocalSharedRepository, installPath, m_Logger, m_DependenciesRepository);


if (File.Exists(versionFile))
{
installedVersion = Version.Parse(File.ReadAllText(versionFile));
installedVersion = SemanticVersion.Parse(File.ReadAllText(versionFile));
}

if (installedVersion == application.Version)
Expand All @@ -80,7 +80,7 @@ public void Install(string path, ApplicationInfo application)
{
string packageId = application.ApplicationId;
var package = (from p in projectManager.GetInstalledPackages(packageId)
where p.Id == packageId && p.Version == new SemanticVersion(installedVersion)
where p.Id == packageId && p.Version == installedVersion
select p).ToList<IPackage>().FirstOrDefault<IPackage>();
if (package != null)
projectManager.UninstallPackage(package, true);
Expand All @@ -94,7 +94,7 @@ public void Install(string path, ApplicationInfo application)
{
cleanUpInstallFolder(installPath);
}
projectManager.InstallPackage(application.ApplicationId, new SemanticVersion(application.Version));
projectManager.InstallPackage(application.ApplicationId, application.Version);
File.WriteAllText(versionFile, application.Version.ToString());
}

Expand Down
8 changes: 5 additions & 3 deletions src/Inceptum.AppServer/Hosting/ApplicationInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using Castle.Windsor;
using Inceptum.AppServer.Model;
using Inceptum.AppServer.Utils;
using NuGet;
using ILogger = Castle.Core.Logging.ILogger;

namespace Inceptum.AppServer.Hosting
{
Expand All @@ -29,7 +31,7 @@ public class ApplicationInstance : IDisposable, IObservable<HostedAppStatus>, IA
private readonly object m_ServiceHostLock = new object();
private readonly Subject<HostedAppStatus> m_StatusSubject = new Subject<HostedAppStatus>();
private readonly object m_SyncRoot = new object();
private Version m_ActualVersion;
private SemanticVersion m_ActualVersion;
private ChannelFactory<IApplicationHost> m_AppHostFactory;
private IApplicationHost m_ApplicationHost;
private Task m_CurrentTask;
Expand Down Expand Up @@ -92,7 +94,7 @@ private set
}
}

public Version ActualVersion
public SemanticVersion ActualVersion
{
get
{
Expand Down Expand Up @@ -236,7 +238,7 @@ private void resetIpcHost()
}


public void UpdateConfig(Version actualVersion, string environment, string user, string password, LoggerLevel logLevel, string defaultConfiguration,
public void UpdateConfig(SemanticVersion actualVersion, string environment, string user, string password, LoggerLevel logLevel, string defaultConfiguration,
long maxLogSize, LogLimitReachedAction logLimitReachedAction)
{
m_MaxLogSize = maxLogSize;
Expand Down
Loading