From 4f509cd8583a190b287ccf456ad947f9a96908f2 Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Fri, 20 Jan 2017 22:05:19 +0800 Subject: [PATCH 1/7] Introduced new csproj for VS2017 (with netcore support) Updated code to fix compilation issues for .NetCore Introduced cake.build file to handle compilation/tests/packaging Updated appveyor.yml to use cake script and to push artifact on myGet --- .gitignore | 6 + GlobalAssemblyVersion.cs | 11 + README.md | 13 +- SlackAPI.Console/Properties/AssemblyInfo.cs | 13 -- SlackAPI.Console/SlackAPI.Console.csproj | 3 + SlackAPI.NetCore.sln | 48 +++++ .../Configuration/IntegrationFixture.cs | 5 +- SlackAPI.Tests/JoinDirectMessageChannel.cs | 2 +- SlackAPI.Tests/Properties/AssemblyInfo.cs | 13 -- SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj | 44 ++++ SlackAPI.Tests/SlackAPI.Tests.csproj | 3 + SlackAPI.Tests/app.config | 3 + SlackAPI.nuspec | 25 --- SlackAPI/Extensions.cs | 8 +- SlackAPI/Properties/AssemblyInfo.cs | 15 +- SlackAPI/SlackAPI.NetCore.csproj | 59 ++++++ SlackAPI/SlackAPI.csproj | 7 +- SlackAPI/SlackSocket.cs | 75 +++++-- appveyor.yml | 50 ++--- build.cake | 139 +++++++++++++ build.ps1 | 189 ++++++++++++++++++ global.json | 4 + 22 files changed, 612 insertions(+), 123 deletions(-) create mode 100644 GlobalAssemblyVersion.cs create mode 100755 SlackAPI.NetCore.sln mode change 100644 => 100755 SlackAPI.Tests/Configuration/IntegrationFixture.cs create mode 100755 SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj mode change 100644 => 100755 SlackAPI.Tests/app.config delete mode 100644 SlackAPI.nuspec create mode 100755 SlackAPI/SlackAPI.NetCore.csproj create mode 100644 build.cake create mode 100644 build.ps1 create mode 100644 global.json diff --git a/.gitignore b/.gitignore index 8e281d6..84cd940 100644 --- a/.gitignore +++ b/.gitignore @@ -220,3 +220,9 @@ pip-log.txt packages *.private .vs/config/applicationhost.config + +#.Net core +*.lock.json + +# Cake +tools/ diff --git a/GlobalAssemblyVersion.cs b/GlobalAssemblyVersion.cs new file mode 100644 index 0000000..01acc99 --- /dev/null +++ b/GlobalAssemblyVersion.cs @@ -0,0 +1,11 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by Cake. +// +//------------------------------------------------------------------------------ +using System.Reflection; + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0.0")] + diff --git a/README.md b/README.md index 147b102..2d3ac70 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ [![Build status](https://ci.appveyor.com/api/projects/status/5n9e7sruxpo0mw79/branch/master?svg=true)](https://ci.appveyor.com/project/Inumedia/slackapi/branch/master) +[![NuGet](https://img.shields.io/nuget/v/SlackAPI.svg)](https://www.nuget.org/packages/SlackAPI/) +[![MyGet Pre Release](https://img.shields.io/myget/slackapi/vpre/SlackAPI.svg)](https://www.myget.org/feed/slackapi/package/nuget/SlackAPI) # SlackAPI @@ -35,8 +37,9 @@ The project **SlackAPI.Tests** requires a valid `config.json` file for tests. Yo - *directMessageUser* : A Slack member username - *clientId*/*clientSecret*/*authCode* : Not used -# Creating NuGet package - -Example: - -```nuget pack SlackAPI.nuspec -version 1.2.3``` +# NuGet package +SlackAPI NuGet package is build with following platforms support: +- .NET Framework 4.5 (support .NET Framework 4.5 and 4.5.1) +- .NET Standard 1.6 (support .NET Framework 4.6 and later) +- .NET Standard 1.3 (support UWP). + - The version cannot detect SlackSocketRouting attributes in loaded assemblies (used to extend SlackAPI to handle custom messages). diff --git a/SlackAPI.Console/Properties/AssemblyInfo.cs b/SlackAPI.Console/Properties/AssemblyInfo.cs index 56ade80..aaea0be 100644 --- a/SlackAPI.Console/Properties/AssemblyInfo.cs +++ b/SlackAPI.Console/Properties/AssemblyInfo.cs @@ -21,16 +21,3 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("523b8aa3-1079-44e3-9dd3-70066a09684b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SlackAPI.Console/SlackAPI.Console.csproj b/SlackAPI.Console/SlackAPI.Console.csproj index 83e2658..890f211 100644 --- a/SlackAPI.Console/SlackAPI.Console.csproj +++ b/SlackAPI.Console/SlackAPI.Console.csproj @@ -42,6 +42,9 @@ + + Properties\GlobalAssemblyVersion.cs + diff --git a/SlackAPI.NetCore.sln b/SlackAPI.NetCore.sln new file mode 100755 index 0000000..0206c0f --- /dev/null +++ b/SlackAPI.NetCore.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26014.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI.NetCore", "\\vmware-host\Shared Folders\Documents\Git\GitHub\SlackAPI\SlackAPI\SlackAPI.NetCore.csproj", "{7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI.Tests.NetCore", "\\vmware-host\Shared Folders\Documents\Git\GitHub\SlackAPI\SlackAPI.Tests\SlackAPI.Tests.NetCore.csproj", "{DEFA9559-0F8F-4C38-9644-67A080EDC46D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|x64.ActiveCfg = Debug|x64 + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|x64.Build.0 = Debug|x64 + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|x86.ActiveCfg = Debug|x86 + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|x86.Build.0 = Debug|x86 + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|Any CPU.Build.0 = Release|Any CPU + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|x64.ActiveCfg = Release|x64 + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|x64.Build.0 = Release|x64 + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|x86.ActiveCfg = Release|x86 + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|x86.Build.0 = Release|x86 + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|x64.ActiveCfg = Debug|x64 + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|x64.Build.0 = Debug|x64 + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|x86.ActiveCfg = Debug|x86 + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|x86.Build.0 = Debug|x86 + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|Any CPU.Build.0 = Release|Any CPU + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|x64.ActiveCfg = Release|x64 + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|x64.Build.0 = Release|x64 + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|x86.ActiveCfg = Release|x86 + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/SlackAPI.Tests/Configuration/IntegrationFixture.cs b/SlackAPI.Tests/Configuration/IntegrationFixture.cs old mode 100644 new mode 100755 index e539390..2ee925d --- a/SlackAPI.Tests/Configuration/IntegrationFixture.cs +++ b/SlackAPI.Tests/Configuration/IntegrationFixture.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Reflection; using Newtonsoft.Json; using SlackAPI.Tests.Helpers; using Xunit; @@ -29,7 +30,9 @@ public void Dispose() private SlackConfig GetConfig() { - string fileName = Path.Combine(Environment.CurrentDirectory, @"configuration\config.json"); + var currentAssembly = this.GetType().GetTypeInfo().Assembly.Location; + var assemblyDirectory = Path.GetDirectoryName(currentAssembly); + string fileName = Path.Combine(assemblyDirectory, @"configuration\config.json"); string json = System.IO.File.ReadAllText(fileName); var jsonObject = new {slack = (SlackConfig)null }; diff --git a/SlackAPI.Tests/JoinDirectMessageChannel.cs b/SlackAPI.Tests/JoinDirectMessageChannel.cs index 89f8936..237ede3 100644 --- a/SlackAPI.Tests/JoinDirectMessageChannel.cs +++ b/SlackAPI.Tests/JoinDirectMessageChannel.cs @@ -24,7 +24,7 @@ public void ShouldJoinDirectMessageChannel() JoinDirectMessageChannelResponse actual = null; string userName = this.fixture.Config.DirectMessageUser; - string user = client.Users.First(x => x.name.Equals(userName, StringComparison.InvariantCultureIgnoreCase)).id; + string user = client.Users.First(x => x.name.Equals(userName, StringComparison.OrdinalIgnoreCase)).id; // when using (var sync = new InSync(nameof(SlackClient.JoinDirectMessageChannel))) diff --git a/SlackAPI.Tests/Properties/AssemblyInfo.cs b/SlackAPI.Tests/Properties/AssemblyInfo.cs index 5f53664..14ebb5c 100644 --- a/SlackAPI.Tests/Properties/AssemblyInfo.cs +++ b/SlackAPI.Tests/Properties/AssemblyInfo.cs @@ -21,16 +21,3 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("c254f6ff-81d4-46df-aa21-3d1a6456253b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj b/SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj new file mode 100755 index 0000000..b57c649 --- /dev/null +++ b/SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj @@ -0,0 +1,44 @@ + + + net451;netcoreapp1.0 + SlackAPI.Tests + false + false + false + false + false + false + Exe + + + + + + + configuration/config.json + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + $(DefineConstants);RELEASE + + \ No newline at end of file diff --git a/SlackAPI.Tests/SlackAPI.Tests.csproj b/SlackAPI.Tests/SlackAPI.Tests.csproj index 7c3a1f1..714cd1f 100644 --- a/SlackAPI.Tests/SlackAPI.Tests.csproj +++ b/SlackAPI.Tests/SlackAPI.Tests.csproj @@ -59,6 +59,9 @@ + + Properties\GlobalAssemblyVersion.cs + diff --git a/SlackAPI.Tests/app.config b/SlackAPI.Tests/app.config old mode 100644 new mode 100755 index 8460dd4..21f024a --- a/SlackAPI.Tests/app.config +++ b/SlackAPI.Tests/app.config @@ -8,4 +8,7 @@ + + + \ No newline at end of file diff --git a/SlackAPI.nuspec b/SlackAPI.nuspec deleted file mode 100644 index f686459..0000000 --- a/SlackAPI.nuspec +++ /dev/null @@ -1,25 +0,0 @@ - - - - SlackAPI - 1.0.4.1 - SlackAPI - Inumedia - Inumedia - http://choosealicense.com/licenses/mit/ - true - C# implementation of the Slack team communication platform API. - The MIT License (MIT) - - en-US - - - - - - - - - - - diff --git a/SlackAPI/Extensions.cs b/SlackAPI/Extensions.cs index 8dc3f5d..194a948 100644 --- a/SlackAPI/Extensions.cs +++ b/SlackAPI/Extensions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Runtime.Serialization; using Newtonsoft.Json; namespace SlackAPI @@ -27,18 +26,17 @@ public static string ToProperTimeStamp(this DateTime that, bool toUTC = true) public static K Deserialize(this string data) where K : class { - return JsonConvert.DeserializeObject(data, CreateSettings(data)); + return JsonConvert.DeserializeObject(data, CreateSettings()); } public static object Deserialize(this string data, Type type) { - return JsonConvert.DeserializeObject(data, type, CreateSettings(data)); + return JsonConvert.DeserializeObject(data, type, CreateSettings()); } - private static JsonSerializerSettings CreateSettings(object contextData) + private static JsonSerializerSettings CreateSettings() { JsonSerializerSettings settings = new JsonSerializerSettings(); - settings.Context = new StreamingContext(StreamingContextStates.Other, contextData); settings.Converters = Converters; return settings; diff --git a/SlackAPI/Properties/AssemblyInfo.cs b/SlackAPI/Properties/AssemblyInfo.cs index 4ae85da..cfb52e4 100644 --- a/SlackAPI/Properties/AssemblyInfo.cs +++ b/SlackAPI/Properties/AssemblyInfo.cs @@ -22,17 +22,4 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("80fe3ab4-f0d5-4fee-a6ae-524b523cebcc")] -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.4.1")] -[assembly: AssemblyFileVersion("1.0.4.1")] - -[assembly: InternalsVisibleTo("SlackAPI.Tests")] \ No newline at end of file +[assembly: InternalsVisibleTo("SlackAPI.Tests")] diff --git a/SlackAPI/SlackAPI.NetCore.csproj b/SlackAPI/SlackAPI.NetCore.csproj new file mode 100755 index 0000000..3e5be5c --- /dev/null +++ b/SlackAPI/SlackAPI.NetCore.csproj @@ -0,0 +1,59 @@ + + + A Slack wrapper for direct interaction with their APIs. + Inumedia - Copyright © 2014 + SlackAPI + en-US + 1.0.0 + + Inumedia + net45;netstandard1.6;netstandard1.3 + SlackAPI + https://github.com/Inumedia/SlackAPI + http://choosealicense.com/licenses/mit/ + true + git + https://github.com/Inumedia/SlackAPI + false + false + false + false + false + false + + + + + + + + + 9.0.1 + + + + + 4.0 + + + + + + + + + + + + + + + + + + SlackAPI + + + $(DefineConstants);RELEASE + + diff --git a/SlackAPI/SlackAPI.csproj b/SlackAPI/SlackAPI.csproj index 08fd672..1a10280 100644 --- a/SlackAPI/SlackAPI.csproj +++ b/SlackAPI/SlackAPI.csproj @@ -17,7 +17,7 @@ full false bin\Debug\ - DEBUG;TRACE + TRACE;DEBUG;NET45 prompt 4 @@ -25,7 +25,7 @@ pdbonly true bin\Release\ - TRACE + TRACE;NET45 prompt 4 @@ -44,6 +44,9 @@ + + Properties\GlobalAssemblyVersion.cs + diff --git a/SlackAPI/SlackSocket.cs b/SlackAPI/SlackSocket.cs index 66db8af..dc541eb 100644 --- a/SlackAPI/SlackSocket.cs +++ b/SlackAPI/SlackSocket.cs @@ -10,6 +10,10 @@ using System.Threading.Tasks; using System.Linq; +#if NETSTANDARD1_6 +using Microsoft.Extensions.DependencyModel; +#endif + namespace SlackAPI { public class SlackSocket @@ -37,23 +41,52 @@ public class SlackSocket static SlackSocket() { routing = new Dictionary>(); - foreach (Assembly assy in AppDomain.CurrentDomain.GetAssemblies()) +#if NET45 + var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GlobalAssemblyCache == false); +#elif NETSTANDARD1_6 + var assemblies = DependencyContext.Default.GetDefaultAssemblyNames().Select(Assembly.Load); +#elif NETSTANDARD1_3 + var assemblies = new[] { typeof(SlackSocket).GetType().GetTypeInfo().Assembly }; +#warning Autodetection not supported +#else +#error Platform not supported +#endif + foreach (Assembly assembly in assemblies) { - if (!assy.GlobalAssemblyCache) - foreach (Type t in assy.GetTypes()) - foreach (SlackSocketRouting route in t.GetCustomAttributes()) + Type[] assemblyTypes; + try + { + assemblyTypes = assembly.GetTypes(); + } + catch (ReflectionTypeLoadException) + { + return; + } + + foreach (Type type in assemblyTypes) + { + foreach (SlackSocketRouting route in type.GetTypeInfo().GetCustomAttributes()) + { + if (!routing.ContainsKey(route.Type)) { - if (!routing.ContainsKey(route.Type)) - routing.Add(route.Type, new Dictionary() + routing.Add(route.Type, new Dictionary() { - {route.SubType ?? "null", t} + {route.SubType ?? "null", type} }); + } + else + { + if (!routing[route.Type].ContainsKey(route.SubType ?? "null")) + { + routing[route.Type].Add(route.SubType ?? "null", type); + } else - if (!routing[route.Type].ContainsKey(route.SubType ?? "null")) - routing[route.Type].Add(route.SubType ?? "null", t); - else - throw new InvalidProgramException("Cannot have two socket message types with the same type and subtype!"); + { + throw new InvalidProgramException("Cannot have two socket message types with the same type and subtype!"); + } } + } + } } } @@ -78,17 +111,17 @@ void BuildRoutes(object routingTo) Type routingToType = routingTo.GetType(); Type slackMessage = typeof(SlackSocketMessage); - foreach (MethodInfo m in routingTo.GetType().GetMethods(BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public)) + foreach (MethodInfo m in routingTo.GetType().GetMethods(BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public)) { ParameterInfo[] parameters = m.GetParameters(); if (parameters.Length != 1) continue; - if (parameters[0].ParameterType.IsSubclassOf(slackMessage)) + if (parameters[0].ParameterType.GetTypeInfo().IsSubclassOf(slackMessage)) { Type t = parameters[0].ParameterType; - foreach (SlackSocketRouting route in t.GetCustomAttributes()) + foreach (SlackSocketRouting route in t.GetTypeInfo().GetCustomAttributes()) { Type genericAction = typeof(Action<>).MakeGenericType(parameters[0].ParameterType); - Delegate d = Delegate.CreateDelegate(genericAction, routingTo, m, false); + Delegate d = m.CreateDelegate(genericAction, routingTo); if (d == null) { System.Diagnostics.Debug.WriteLine(string.Format("Couldn't create delegate for {0}.{1}", routingToType.FullName, m.Name)); @@ -125,7 +158,7 @@ public void Send(SlackSocketMessage message) //socket.Send(JsonConvert.SerializeObject(message)); if (string.IsNullOrEmpty(message.type)){ - IEnumerable routes = message.GetType().GetCustomAttributes(); + IEnumerable routes = message.GetType().GetTypeInfo().GetCustomAttributes(); SlackSocketRouting route = null; foreach (SlackSocketRouting r in routes) @@ -142,14 +175,14 @@ public void Send(SlackSocketMessage message) sendingQueue.Push(JsonConvert.SerializeObject(message, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); if (Interlocked.CompareExchange(ref currentlySending, 1, 0) == 0) - ThreadPool.QueueUserWorkItem(HandleSending); + Task.Factory.StartNew(HandleSending); } public void BindCallback(Action callback) { Type t = typeof(K); - foreach (SlackSocketRouting route in t.GetCustomAttributes()) + foreach (SlackSocketRouting route in t.GetTypeInfo().GetCustomAttributes()) { if (!routes.ContainsKey(route.Type)) routes.Add(route.Type, new Dictionary()); @@ -163,7 +196,7 @@ public void BindCallback(Action callback) public void UnbindCallback(Action callback) { Type t = typeof(K); - foreach (SlackSocketRouting route in t.GetCustomAttributes()) + foreach (SlackSocketRouting route in t.GetTypeInfo().GetCustomAttributes()) { Delegate d = routes.ContainsKey(route.Type) ? (routes.ContainsKey(route.SubType ?? "null") ? routes[route.Type][route.SubType ?? "null"] : null) : null; if (d != null) @@ -249,7 +282,7 @@ void HandleMessage(SlackSocketMessage message, string data) else { //I believe this method is slower than the former. If I'm wrong we can just use this instead. :D - Type t = routes[message.type][message.subtype ?? "null"].Method.GetParameters()[0].ParameterType; + Type t = routes[message.type][message.subtype ?? "null"].GetMethodInfo().GetParameters()[0].ParameterType; o = data.Deserialize(t); } routes[message.type][message.subtype ?? "null"].DynamicInvoke(o); @@ -269,7 +302,7 @@ void HandleMessage(SlackSocketMessage message, string data) } } - void HandleSending(object stateful) + void HandleSending() { string message; while (sendingQueue.Pop(out message) && socket.State == WebSocketState.Open && !cts.Token.IsCancellationRequested) diff --git a/appveyor.yml b/appveyor.yml index 6b9c059..c922a3c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,19 +1,13 @@ -version: 1.0.4.{build} - -configuration: Release -platform: Any CPU +version: 1.0.5.{build} +image: Visual Studio 2015 pull_requests: do_not_increment_build_number: true -skip_branch_with_pr: true +nuget: + disable_publish_on_pr: true -assembly_info: - patch: true - file: '**\AssemblyInfo.*' - assembly_version: '{version}' - assembly_file_version: '{version}' - assembly_informational_version: '{version}' +skip_branch_with_pr: true before_build: - ps: >- @@ -34,19 +28,29 @@ before_build: "@ $config | Set-Content SlackAPI.Tests\Configuration\config.json -- nuget restore - -build: - project: SlackAPI.sln - verbosity: minimal -after_build: -- nuget pack SlackAPI.nuspec -Version %APPVEYOR_BUILD_VERSION% +build_script: +- ps: .\build.ps1 -test: - assemblies: - - SlackAPI.Tests\bin\Release\SlackAPI.Tests.dll +test: off artifacts: -- path: SlackAPI*.nupkg - name: SlackAPI Nuget package +- path: '.\artifacts\**\*.nupkg' + name: Nuget packages + +deploy: +- provider: NuGet + server: https://www.myget.org/F/slackapi/api/v2 + api_key: + secure: dt+bmkFjmkMgVdDXaaqTC4IRORfSrBSEePOGaaVPkEsKs/lGxxth21bkkBqMuJqM + # Deploy symbol package too + skip_symbols: false + symbol_server: https://www.myget.org/F/slackapi/symbols/api/v2/package + +#- provider: NuGet +# name: production +# api_key: +# secure: OVMRfHowHPun4n8cJXPNGg== +# on: +# branch: master +# appveyor_repo_tag: true diff --git a/build.cake b/build.cake new file mode 100644 index 0000000..33c89d6 --- /dev/null +++ b/build.cake @@ -0,0 +1,139 @@ +#addin nuget:?package=Cake.Git +#addin "MagicChunks" + +var configuration = Argument("configuration", "Release"); +var target = Argument("target", "Default"); + +var mainProject = File("./SlackAPI/SlackApi.Netcore.csproj"); +var testProject = File("./SlackAPI.Tests/SlackApi.Tests.NetCore.csproj"); +var projects = new[] { mainProject, testProject }; +var artifactsDirectory = Directory("./artifacts"); +var revision = AppVeyor.IsRunningOnAppVeyor ? AppVeyor.Environment.Build.Number : 0; +var version = AppVeyor.IsRunningOnAppVeyor ? new Version(AppVeyor.Environment.Build.Version).ToString(3) : "1.0.0"; +var globalAssemblyInfo = File("./GlobalAssemblyVersion.cs"); + +var generatedVersion = ""; +var generatedSuffix = ""; + + +Task("Clean") + .Does(() => +{ + CleanDirectory(artifactsDirectory); +}); + + +Task("Restore-Packages") + .Does(() => +{ + foreach(var project in projects) + { + DotNetCoreRestore(project); + } +}); + + +Task("Generate-Versionning") + .Does(() => +{ + generatedVersion = version + "." + revision; + Information("Generated version '{0}'", generatedVersion); + + var branch = (AppVeyor.IsRunningOnAppVeyor ? AppVeyor.Environment.Repository.Branch : GitBranchCurrent(".").FriendlyName).Replace('/', '-'); + generatedSuffix = (branch == "master" && revision > 0) ? "" : branch.Substring(0, Math.Min(10, branch.Length)) + "-" + revision; + Information("Generated suffix '{0}'", generatedSuffix); +}); + + +Task("Patch-GlobalAssemblyVersions") + .IsDependentOn("Generate-Versionning") + .Does(() => +{ + CreateAssemblyInfo(globalAssemblyInfo, new AssemblyInfoSettings { + FileVersion = generatedVersion, + InformationalVersion = version + "-" + generatedSuffix, + Version = generatedVersion + } + ); +}); + + +Task("Patch-ProjectJson") + .IsDependentOn("Generate-Versionning") + .Does(() => +{ + TransformConfig( + mainProject, + mainProject, + new TransformationCollection + { + { "Project/PropertyGroup/VersionPrefix", version }, + { "Project/PropertyGroup/VersionSuffix", generatedSuffix } + } + ); +}); + + +Task("Patch") + .IsDependentOn("Patch-GlobalAssemblyVersions") + .IsDependentOn("Patch-ProjectJson"); + + +Task("Build") + .IsDependentOn("Restore-Packages") + .IsDependentOn("Patch") + .Does(() => +{ + foreach(var project in projects) + { + DotNetCoreBuild( + project, + new DotNetCoreBuildSettings + { + Configuration = configuration + } + ); + } +}); + + +Task("Test") + .IsDependentOn("Restore-Packages") + .IsDependentOn("Patch") + .Does(() => +{ + DotNetCoreTest( + testProject, + new DotNetCoreTestSettings + { + Configuration = configuration + } + ); +}); + + +Task("Pack") + .IsDependentOn("Clean") + .IsDependentOn("Build") + .IsDependentOn("Test") + .Does(() => +{ + DotNetCorePack( + mainProject, + new DotNetCorePackSettings + { + Configuration = configuration, + OutputDirectory = artifactsDirectory, + VersionSuffix = generatedSuffix, + ArgumentCustomization = args => args.Append("--include-symbols") + } + ); + +}); + + +Task("Default") + .IsDependentOn("Pack"); + + +RunTarget(target); diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..44de579 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,189 @@ +########################################################################## +# This is the Cake bootstrapper script for PowerShell. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## + +<# + +.SYNOPSIS +This is a Powershell script to bootstrap a Cake build. + +.DESCRIPTION +This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) +and execute your Cake build script with the parameters you provide. + +.PARAMETER Script +The build script to execute. +.PARAMETER Target +The build script target to run. +.PARAMETER Configuration +The build configuration to use. +.PARAMETER Verbosity +Specifies the amount of information to be displayed. +.PARAMETER Experimental +Tells Cake to use the latest Roslyn release. +.PARAMETER WhatIf +Performs a dry run of the build script. +No tasks will be executed. +.PARAMETER Mono +Tells Cake to use the Mono scripting engine. +.PARAMETER SkipToolPackageRestore +Skips restoring of packages. +.PARAMETER ScriptArgs +Remaining arguments are added here. + +.LINK +http://cakebuild.net + +#> + +[CmdletBinding()] +Param( + [string]$Script = "build.cake", + [string]$Target = "Default", + [ValidateSet("Release", "Debug")] + [string]$Configuration = "Release", + [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] + [string]$Verbosity = "Verbose", + [switch]$Experimental, + [Alias("DryRun","Noop")] + [switch]$WhatIf, + [switch]$Mono, + [switch]$SkipToolPackageRestore, + [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] + [string[]]$ScriptArgs +) + +[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null +function MD5HashFile([string] $filePath) +{ + if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) + { + return $null + } + + [System.IO.Stream] $file = $null; + [System.Security.Cryptography.MD5] $md5 = $null; + try + { + $md5 = [System.Security.Cryptography.MD5]::Create() + $file = [System.IO.File]::OpenRead($filePath) + return [System.BitConverter]::ToString($md5.ComputeHash($file)) + } + finally + { + if ($file -ne $null) + { + $file.Dispose() + } + } +} + +Write-Host "Preparing to run build script..." + +if(!$PSScriptRoot){ + $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent +} + +$TOOLS_DIR = Join-Path $PSScriptRoot "tools" +$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" +$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" +$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" +$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" +$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" + +# Should we use mono? +$UseMono = ""; +if($Mono.IsPresent) { + Write-Verbose -Message "Using the Mono based scripting engine." + $UseMono = "-mono" +} + +# Should we use the new Roslyn? +$UseExperimental = ""; +if($Experimental.IsPresent -and !($Mono.IsPresent)) { + Write-Verbose -Message "Using experimental version of Roslyn." + $UseExperimental = "-experimental" +} + +# Is this a dry run? +$UseDryRun = ""; +if($WhatIf.IsPresent) { + $UseDryRun = "-dryrun" +} + +# Make sure tools folder exists +if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { + Write-Verbose -Message "Creating tools directory..." + New-Item -Path $TOOLS_DIR -Type directory | out-null +} + +# Make sure that packages.config exist. +if (!(Test-Path $PACKAGES_CONFIG)) { + Write-Verbose -Message "Downloading packages.config..." + try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch { + Throw "Could not download packages.config." + } +} + +# Try find NuGet.exe in path if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Trying to find nuget.exe in PATH..." + $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_) } + $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 + if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { + Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." + $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName + } +} + +# Try download NuGet.exe if not exists +if (!(Test-Path $NUGET_EXE)) { + Write-Verbose -Message "Downloading NuGet.exe..." + try { + (New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE) + } catch { + Throw "Could not download NuGet.exe." + } +} + +# Save nuget.exe path to environment to be available to child processed +$ENV:NUGET_EXE = $NUGET_EXE + +# Restore tools from NuGet? +if(-Not $SkipToolPackageRestore.IsPresent) { + Push-Location + Set-Location $TOOLS_DIR + + # Check for changes in packages.config and remove installed tools if true. + [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) + if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or + ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { + Write-Verbose -Message "Missing or changed package.config hash..." + Remove-Item * -Recurse -Exclude packages.config,nuget.exe + } + + Write-Verbose -Message "Restoring tools from NuGet..." + $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occured while restoring NuGet tools." + } + else + { + $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" + } + Write-Verbose -Message ($NuGetOutput | out-string) + Pop-Location +} + +# Make sure that Cake has been installed. +if (!(Test-Path $CAKE_EXE)) { + Throw "Could not find Cake.exe at $CAKE_EXE" +} + +# Start Cake +Write-Host "Running build script..." +Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" +exit $LASTEXITCODE \ No newline at end of file diff --git a/global.json b/global.json new file mode 100644 index 0000000..77a2f4c --- /dev/null +++ b/global.json @@ -0,0 +1,4 @@ +{ + "projects": [ "SlackAPI", "SlackAPI.Tests" ], + "sdk": { "version": "1.0.0-preview4-004233" } +} From e52ce3463efc9e41c79be7a382a388bd53591962 Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Fri, 20 Jan 2017 23:35:38 +0800 Subject: [PATCH 2/7] Manually install required .netcore version on AppVeyor --- appveyor.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index c922a3c..15b96ea 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,10 @@ version: 1.0.5.{build} image: Visual Studio 2015 +environment: + matrix: + - CLI_VERSION: 1.0.0-preview4-004233 + pull_requests: do_not_increment_build_number: true @@ -9,6 +13,12 @@ nuget: skip_branch_with_pr: true +install: + - ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\install.ps1" + - ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli" + - ps: '& .\install.ps1 -Channel "preview" -version "$env:CLI_VERSION" -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath' + - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" + before_build: - ps: >- $config = @" From 486c368a72850c94ba904aa0a93aee3814ac175e Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Sat, 21 Jan 2017 00:00:26 +0800 Subject: [PATCH 3/7] Fixed issue with version generated by AppVeyor PR (x.y.z-random) --- build.cake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.cake b/build.cake index 33c89d6..90ac73a 100644 --- a/build.cake +++ b/build.cake @@ -9,7 +9,7 @@ var testProject = File("./SlackAPI.Tests/SlackApi.Tests.NetCore.csproj"); var projects = new[] { mainProject, testProject }; var artifactsDirectory = Directory("./artifacts"); var revision = AppVeyor.IsRunningOnAppVeyor ? AppVeyor.Environment.Build.Number : 0; -var version = AppVeyor.IsRunningOnAppVeyor ? new Version(AppVeyor.Environment.Build.Version).ToString(3) : "1.0.0"; +var version = AppVeyor.IsRunningOnAppVeyor ? new Version(AppVeyor.Environment.Build.Version.Split('-')[0]).ToString(3) : "1.0.0"; var globalAssemblyInfo = File("./GlobalAssemblyVersion.cs"); var generatedVersion = ""; @@ -106,7 +106,8 @@ Task("Test") testProject, new DotNetCoreTestSettings { - Configuration = configuration + Configuration = configuration, + Verbose = true } ); }); From 7745530f1eb37b6d8afbf019a96952db96464ccb Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Mon, 23 Jan 2017 09:18:20 +0800 Subject: [PATCH 4/7] Removed absolute paths in VS2017 sln --- SlackAPI.NetCore.sln | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SlackAPI.NetCore.sln b/SlackAPI.NetCore.sln index 0206c0f..652106c 100755 --- a/SlackAPI.NetCore.sln +++ b/SlackAPI.NetCore.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26014.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI.NetCore", "\\vmware-host\Shared Folders\Documents\Git\GitHub\SlackAPI\SlackAPI\SlackAPI.NetCore.csproj", "{7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI.NetCore", "SlackAPI\SlackAPI.NetCore.csproj", "{7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI.Tests.NetCore", "\\vmware-host\Shared Folders\Documents\Git\GitHub\SlackAPI\SlackAPI.Tests\SlackAPI.Tests.NetCore.csproj", "{DEFA9559-0F8F-4C38-9644-67A080EDC46D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI.Tests.NetCore", "SlackAPI.Tests\SlackAPI.Tests.NetCore.csproj", "{DEFA9559-0F8F-4C38-9644-67A080EDC46D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From 4d5da5f9c5f53c2470f1d0883bf25c3da2223614 Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Mon, 13 Mar 2017 19:38:47 +0800 Subject: [PATCH 5/7] Updated Solution and projects to VS2017 and .NetCore SDK 1.0.0 / Updated nuget packages to latest versions --- SlackAPI.NetCore.sln | 22 +----------- SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj | 38 ++++++++------------ SlackAPI/SlackAPI.NetCore.csproj | 20 +++-------- global.json | 4 --- 4 files changed, 21 insertions(+), 63 deletions(-) delete mode 100644 global.json diff --git a/SlackAPI.NetCore.sln b/SlackAPI.NetCore.sln index 652106c..f77c444 100755 --- a/SlackAPI.NetCore.sln +++ b/SlackAPI.NetCore.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26014.0 +VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI.NetCore", "SlackAPI\SlackAPI.NetCore.csproj", "{7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}" EndProject @@ -10,37 +10,17 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|x64.ActiveCfg = Debug|x64 - {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|x64.Build.0 = Debug|x64 - {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|x86.ActiveCfg = Debug|x86 - {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Debug|x86.Build.0 = Debug|x86 {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|Any CPU.ActiveCfg = Release|Any CPU {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|Any CPU.Build.0 = Release|Any CPU - {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|x64.ActiveCfg = Release|x64 - {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|x64.Build.0 = Release|x64 - {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|x86.ActiveCfg = Release|x86 - {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|x86.Build.0 = Release|x86 {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|x64.ActiveCfg = Debug|x64 - {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|x64.Build.0 = Debug|x64 - {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|x86.ActiveCfg = Debug|x86 - {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Debug|x86.Build.0 = Debug|x86 {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|Any CPU.ActiveCfg = Release|Any CPU {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|Any CPU.Build.0 = Release|Any CPU - {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|x64.ActiveCfg = Release|x64 - {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|x64.Build.0 = Release|x64 - {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|x86.ActiveCfg = Release|x86 - {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj b/SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj index b57c649..84bbd42 100755 --- a/SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj +++ b/SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj @@ -1,6 +1,6 @@  - net451;netcoreapp1.0 + net452;netcoreapp1.0 SlackAPI.Tests false false @@ -8,37 +8,29 @@ false false false - Exe - - - - - configuration/config.json - PreserveNewest - - - - + + + - - - - - - - + + - - - + + + PreserveNewest + + + + + $(DefineConstants);RELEASE - \ No newline at end of file + diff --git a/SlackAPI/SlackAPI.NetCore.csproj b/SlackAPI/SlackAPI.NetCore.csproj index 3e5be5c..737e753 100755 --- a/SlackAPI/SlackAPI.NetCore.csproj +++ b/SlackAPI/SlackAPI.NetCore.csproj @@ -1,4 +1,4 @@ - + A Slack wrapper for direct interaction with their APIs. Inumedia - Copyright © 2014 @@ -22,33 +22,23 @@ false - - - - - - - 9.0.1 - + + - - 4.0 - - - + - + SlackAPI diff --git a/global.json b/global.json deleted file mode 100644 index 77a2f4c..0000000 --- a/global.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "projects": [ "SlackAPI", "SlackAPI.Tests" ], - "sdk": { "version": "1.0.0-preview4-004233" } -} From 3a2106fc8a7819ad37423f249e845f7380ec2397 Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Mon, 13 Mar 2017 19:37:24 +0800 Subject: [PATCH 6/7] Used appveyor VisualStudio 2017 official image. Bumped version to 1.0.6 --- appveyor.yml | 14 ++------------ build.cake | 1 - 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 15b96ea..b9c5120 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,9 +1,5 @@ -version: 1.0.5.{build} -image: Visual Studio 2015 - -environment: - matrix: - - CLI_VERSION: 1.0.0-preview4-004233 +version: 1.0.6.{build} +image: Visual Studio 2017 pull_requests: do_not_increment_build_number: true @@ -13,12 +9,6 @@ nuget: skip_branch_with_pr: true -install: - - ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\install.ps1" - - ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli" - - ps: '& .\install.ps1 -Channel "preview" -version "$env:CLI_VERSION" -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath' - - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" - before_build: - ps: >- $config = @" diff --git a/build.cake b/build.cake index 90ac73a..f7e5d0d 100644 --- a/build.cake +++ b/build.cake @@ -107,7 +107,6 @@ Task("Test") new DotNetCoreTestSettings { Configuration = configuration, - Verbose = true } ); }); From cadeacc76784c02de2130e272c4ae19ce4bf5134 Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Wed, 15 Mar 2017 11:37:11 +0800 Subject: [PATCH 7/7] Customize testresults by appending framework version and push them to AppVeyor manually --- build.cake | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/build.cake b/build.cake index f7e5d0d..b5b2429 100644 --- a/build.cake +++ b/build.cake @@ -1,5 +1,6 @@ #addin nuget:?package=Cake.Git #addin "MagicChunks" +#addin "Cake.FileHelpers" var configuration = Argument("configuration", "Release"); var target = Argument("target", "Default"); @@ -102,13 +103,41 @@ Task("Test") .IsDependentOn("Patch") .Does(() => { - DotNetCoreTest( - testProject, - new DotNetCoreTestSettings + // AppVeyor is unable to differentiate tests from multiple frameworks + // To push all test results on AppVeyor: + // - disable builtin AppVeyor push from XUnit + // - generate MSTest report + // - replace assembly name in test report + // - manualy push test result + + foreach (var framework in new[] { "net452", "netcoreapp1.0"}) + { + DotNetCoreTest( + testProject, + new DotNetCoreTestSettings + { + Configuration = configuration, + Framework = framework, + ArgumentCustomization = args => args.Append("--logger \"trx;LogFileName=result_" + framework + ".trx\""), + EnvironmentVariables = new Dictionary{ + { "APPVEYOR_API_URL", null } + } + } + ); + + if (AppVeyor.IsRunningOnAppVeyor) { - Configuration = configuration, + var testResult = File("./SlackAPI.Tests/TestResults/result_" + framework + ".trx"); + + ReplaceRegexInFiles( + testResult, + @"slackapi\.tests\.dll", + "SlackAPI.Tests." + framework + ".dll", + System.Text.RegularExpressions.RegexOptions.IgnoreCase); + + AppVeyor.UploadTestResults(testResult, AppVeyorTestResultsType.MSTest); } - ); + } });