From 27b59c319bb1058dea0ff01a95d0935eb0e3f244 Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Sat, 20 Oct 2018 19:54:37 +0700 Subject: [PATCH 1/8] Ignore artifacts folder from git --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 671cb8c..bff54b2 100644 --- a/.gitignore +++ b/.gitignore @@ -226,4 +226,5 @@ packages # Cake tools/ -.vs/ \ No newline at end of file +.vs/ +artifacts/ \ No newline at end of file From 17db9407737f3789da190e0250085cfa5d043d4b Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Sat, 20 Oct 2018 21:28:17 +0700 Subject: [PATCH 2/8] Refactored projects to merge netframework and netcore configurations Use a single place (Directory.Build.Props) for metadata configuration (build version, package description, author...) Reduce appveyor configuration and move it in cake.build (less dependencies on CI system) Generate new build versions with part of SHA --- Directory.Build.props | 24 +++ GlobalAssemblyVersion.cs | 11 - SlackAPI.Console/SlackAPI.Console.csproj | 5 +- SlackAPI.NetCore.sln | 28 --- SlackAPI.Tests/Properties/AssemblyInfo.cs | 23 --- SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj | 36 ---- SlackAPI.Tests/SlackAPI.Tests.csproj | 120 +++-------- SlackAPI.Tests/packages.config | 12 -- SlackAPI.sln | 30 ++- SlackAPI/Properties/AssemblyInfo.cs | 25 --- SlackAPI/Properties/InternalsVisibleTo.cs | 3 + SlackAPI/SlackAPI.NetCore.csproj | 49 ----- SlackAPI/SlackAPI.csproj | 199 ++----------------- SlackAPI/SlackSocket.cs | 11 +- SlackAPI/packages.config | 4 - appveyor.yml | 21 -- build.cake | 121 ++++++----- 17 files changed, 141 insertions(+), 581 deletions(-) create mode 100644 Directory.Build.props delete mode 100644 GlobalAssemblyVersion.cs delete mode 100755 SlackAPI.NetCore.sln delete mode 100644 SlackAPI.Tests/Properties/AssemblyInfo.cs delete mode 100755 SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj delete mode 100644 SlackAPI.Tests/packages.config delete mode 100644 SlackAPI/Properties/AssemblyInfo.cs create mode 100644 SlackAPI/Properties/InternalsVisibleTo.cs delete mode 100755 SlackAPI/SlackAPI.NetCore.csproj delete mode 100644 SlackAPI/packages.config diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..5467113 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,24 @@ + + + 1.0.6 + local + + A Slack wrapper for direct interaction with their APIs. + Inumedia - Copyright © 2018 + SlackAPI + en-US + Inumedia + Inumedia + https://github.com/Inumedia/SlackAPI + http://choosealicense.com/licenses/mit/ + true + git + https://github.com/Inumedia/SlackAPI + + + \ No newline at end of file diff --git a/GlobalAssemblyVersion.cs b/GlobalAssemblyVersion.cs deleted file mode 100644 index 01acc99..0000000 --- a/GlobalAssemblyVersion.cs +++ /dev/null @@ -1,11 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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/SlackAPI.Console/SlackAPI.Console.csproj b/SlackAPI.Console/SlackAPI.Console.csproj index 890f211..2795092 100644 --- a/SlackAPI.Console/SlackAPI.Console.csproj +++ b/SlackAPI.Console/SlackAPI.Console.csproj @@ -42,9 +42,6 @@ - - Properties\GlobalAssemblyVersion.cs - @@ -65,4 +62,4 @@ --> - + \ No newline at end of file diff --git a/SlackAPI.NetCore.sln b/SlackAPI.NetCore.sln deleted file mode 100755 index f77c444..0000000 --- a/SlackAPI.NetCore.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -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 -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 - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - 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}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|Any CPU.Build.0 = Release|Any CPU - {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}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/SlackAPI.Tests/Properties/AssemblyInfo.cs b/SlackAPI.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 14ebb5c..0000000 --- a/SlackAPI.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -using Xunit; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SlackAPI.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SlackAPI.Tests")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c254f6ff-81d4-46df-aa21-3d1a6456253b")] diff --git a/SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj b/SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj deleted file mode 100755 index 84bbd42..0000000 --- a/SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj +++ /dev/null @@ -1,36 +0,0 @@ - - - net452;netcoreapp1.0 - SlackAPI.Tests - false - false - false - false - false - false - - - - - - - - - - - - - - - - - PreserveNewest - - - - - - - $(DefineConstants);RELEASE - - diff --git a/SlackAPI.Tests/SlackAPI.Tests.csproj b/SlackAPI.Tests/SlackAPI.Tests.csproj index 1389905..7e702f0 100644 --- a/SlackAPI.Tests/SlackAPI.Tests.csproj +++ b/SlackAPI.Tests/SlackAPI.Tests.csproj @@ -1,109 +1,35 @@ - - - + + - Debug - AnyCPU - {C254F6FF-81D4-46DF-AA21-3D1A6456253B} + net452;netcoreapp2.1 Library - Properties + Full SlackAPI.Tests + SlackAPI.Tests SlackAPI.Tests - v4.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Microsoft.TestPlatform.ObjectModel.11.0.0\lib\net35\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll - True - - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - True - - - - ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll - True - - - ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll - True - - - ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll - True - - - ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll - True - - + - - Properties\GlobalAssemblyVersion.cs - - - - - - - - - - - - - + + + + all + runtime; build; native; contentfiles; analyzers + + - - {0c0a58a8-174e-4a4c-907b-c3569144d15d} - SlackAPI - + + - - - Always + + PreserveNewest - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file + + + $(DefineConstants);RELEASE + + + diff --git a/SlackAPI.Tests/packages.config b/SlackAPI.Tests/packages.config deleted file mode 100644 index 23396f5..0000000 --- a/SlackAPI.Tests/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/SlackAPI.sln b/SlackAPI.sln index 5a1913b..9b364b7 100644 --- a/SlackAPI.sln +++ b/SlackAPI.sln @@ -1,34 +1,28 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlackAPI", "SlackAPI\SlackAPI.csproj", "{0C0A58A8-174E-4A4C-907B-C3569144D15D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI", "SlackAPI\SlackAPI.csproj", "{7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlackAPI.Tests", "SlackAPI.Tests\SlackAPI.Tests.csproj", "{C254F6FF-81D4-46DF-AA21-3D1A6456253B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlackAPI.Tests", "SlackAPI.Tests\SlackAPI.Tests.csproj", "{DEFA9559-0F8F-4C38-9644-67A080EDC46D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlackAPI.Console", "SlackAPI.Console\SlackAPI.Console.csproj", "{19140E48-E1A9-421D-86DB-5AF18EECFEF2}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{9FC74E78-2D91-407E-B4C8-7C89D6CECB5B}" - ProjectSection(SolutionItems) = preProject - LICENSE = LICENSE - README.md = README.md - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0C0A58A8-174E-4A4C-907B-C3569144D15D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0C0A58A8-174E-4A4C-907B-C3569144D15D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0C0A58A8-174E-4A4C-907B-C3569144D15D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0C0A58A8-174E-4A4C-907B-C3569144D15D}.Release|Any CPU.Build.0 = Release|Any CPU - {C254F6FF-81D4-46DF-AA21-3D1A6456253B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C254F6FF-81D4-46DF-AA21-3D1A6456253B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C254F6FF-81D4-46DF-AA21-3D1A6456253B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C254F6FF-81D4-46DF-AA21-3D1A6456253B}.Release|Any CPU.Build.0 = Release|Any CPU + {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}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7EED3D9B-9B7A-49A4-AFBF-599153A47DDA}.Release|Any CPU.Build.0 = Release|Any CPU + {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}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DEFA9559-0F8F-4C38-9644-67A080EDC46D}.Release|Any CPU.Build.0 = Release|Any CPU {19140E48-E1A9-421D-86DB-5AF18EECFEF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {19140E48-E1A9-421D-86DB-5AF18EECFEF2}.Debug|Any CPU.Build.0 = Debug|Any CPU {19140E48-E1A9-421D-86DB-5AF18EECFEF2}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/SlackAPI/Properties/AssemblyInfo.cs b/SlackAPI/Properties/AssemblyInfo.cs deleted file mode 100644 index cfb52e4..0000000 --- a/SlackAPI/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SlackAPI")] -[assembly: AssemblyDescription("A Slack wrapper for direct interaction with their APIs.")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Inumedia")] -[assembly: AssemblyProduct("SlackAPI")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("80fe3ab4-f0d5-4fee-a6ae-524b523cebcc")] - -[assembly: InternalsVisibleTo("SlackAPI.Tests")] diff --git a/SlackAPI/Properties/InternalsVisibleTo.cs b/SlackAPI/Properties/InternalsVisibleTo.cs new file mode 100644 index 0000000..d747d59 --- /dev/null +++ b/SlackAPI/Properties/InternalsVisibleTo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly:InternalsVisibleTo("SlackAPI.Tests")] \ No newline at end of file diff --git a/SlackAPI/SlackAPI.NetCore.csproj b/SlackAPI/SlackAPI.NetCore.csproj deleted file mode 100755 index 737e753..0000000 --- a/SlackAPI/SlackAPI.NetCore.csproj +++ /dev/null @@ -1,49 +0,0 @@ - - - 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 - - - - - - - - - - - - - - - - - - - - - - SlackAPI - - - $(DefineConstants);RELEASE - - diff --git a/SlackAPI/SlackAPI.csproj b/SlackAPI/SlackAPI.csproj index c2ccdea..6890730 100644 --- a/SlackAPI/SlackAPI.csproj +++ b/SlackAPI/SlackAPI.csproj @@ -1,184 +1,27 @@ - - - - - Debug - AnyCPU - {0C0A58A8-174E-4A4C-907B-C3569144D15D} - Library - Properties + + + + net45;netstandard1.3 + Full SlackAPI + SlackAPI SlackAPI - v4.5 - 512 - - true - full - false - bin\Debug\ - TRACE;DEBUG;NET45 - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE;NET45 - prompt - 4 - - - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - True - - - - - - - - - - + - - Properties\GlobalAssemblyVersion.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + + + + + - - - \ No newline at end of file + + + $(DefineConstants);RELEASE + + + diff --git a/SlackAPI/SlackSocket.cs b/SlackAPI/SlackSocket.cs index dc541eb..6e614cf 100644 --- a/SlackAPI/SlackSocket.cs +++ b/SlackAPI/SlackSocket.cs @@ -10,10 +10,6 @@ using System.Threading.Tasks; using System.Linq; -#if NETSTANDARD1_6 -using Microsoft.Extensions.DependencyModel; -#endif - namespace SlackAPI { public class SlackSocket @@ -43,13 +39,8 @@ static SlackSocket() routing = new Dictionary>(); #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 + var assemblies = new[] { typeof(SlackSocket).GetType().GetTypeInfo().Assembly }; #endif foreach (Assembly assembly in assemblies) { diff --git a/SlackAPI/packages.config b/SlackAPI/packages.config deleted file mode 100644 index e1fae9c..0000000 --- a/SlackAPI/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index b9c5120..cbbf860 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,3 @@ -version: 1.0.6.{build} image: Visual Studio 2017 pull_requests: @@ -9,26 +8,6 @@ nuget: skip_branch_with_pr: true -before_build: -- ps: >- - $config = @" - - { - "slack": { - "userAuthToken": "$env:userAuthToken", - "botAuthToken": "$env:botAuthToken", - "testChannel": "$env:testChannel", - "directMessageUser": "$env:directMessageUser", - "authCode": "$env:authCode", - "clientId": "$env:clientId", - "clientSecret": "$env:clientSecret" - } - } - - "@ - - $config | Set-Content SlackAPI.Tests\Configuration\config.json - build_script: - ps: .\build.ps1 diff --git a/build.cake b/build.cake index b5b2429..dfb62e8 100644 --- a/build.cake +++ b/build.cake @@ -1,21 +1,15 @@ -#addin nuget:?package=Cake.Git -#addin "MagicChunks" #addin "Cake.FileHelpers" 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 mainProject = File("./SlackAPI/SlackApi.csproj"); +var testProject = File("./SlackAPI.Tests/SlackApi.Tests.csproj"); +var testConfig = File("./SlackAPI.Tests/Configuration/config.json"); 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.Split('-')[0]).ToString(3) : "1.0.0"; -var globalAssemblyInfo = File("./GlobalAssemblyVersion.cs"); - -var generatedVersion = ""; -var generatedSuffix = ""; - +var versionSuffix = "local.0"; +var isReleaseBuild = false; Task("Clean") .Does(() => @@ -24,65 +18,39 @@ Task("Clean") }); -Task("Restore-Packages") +Task("Configure") .Does(() => { - foreach(var project in projects) + if (AppVeyor.IsRunningOnAppVeyor) { - 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 - } - ); -}); - + isReleaseBuild = AppVeyor.Environment.Repository.Branch == "master" + && AppVeyor.Environment.Repository.Tag.IsTag; -Task("Patch-ProjectJson") - .IsDependentOn("Generate-Versionning") - .Does(() => -{ - TransformConfig( - mainProject, - mainProject, - new TransformationCollection + // If the build is a tag on master, generate a clean version (1.0.0-ci.123) + // Otherwise, append part of the SHA (1.0.0-ci.123+sha.abcdefg) + versionSuffix = $"ci.{AppVeyor.Environment.Build.Number}"; + if (!isReleaseBuild) { - { "Project/PropertyGroup/VersionPrefix", version }, - { "Project/PropertyGroup/VersionSuffix", generatedSuffix } + versionSuffix += $"+sha.{AppVeyor.Environment.Repository.Commit.Id.Substring(0, 7)}"; } - ); -}); + } + var versionPrefix = XmlPeek("./Directory.Build.props", "/Project/PropertyGroup/VersionPrefix"); + var version = string.Join("-", versionPrefix, versionSuffix); + + if (AppVeyor.IsRunningOnAppVeyor) + { + // Update AppVeyor build version so it will match the build version in assemblies and package + AppVeyor.UpdateBuildVersion(version); + } -Task("Patch") - .IsDependentOn("Patch-GlobalAssemblyVersions") - .IsDependentOn("Patch-ProjectJson"); + Information("Using version '{0}'", version); + Information("Release type build (skip symbols): {0}", isReleaseBuild); +}); Task("Build") - .IsDependentOn("Restore-Packages") - .IsDependentOn("Patch") + .IsDependentOn("Configure") .Does(() => { foreach(var project in projects) @@ -91,16 +59,38 @@ Task("Build") project, new DotNetCoreBuildSettings { - Configuration = configuration + Configuration = configuration, + VersionSuffix = versionSuffix } ); } }); +Task("ConfigureTest") + .Does(() => +{ + if (AppVeyor.IsRunningOnAppVeyor) + { + FileWriteText(testConfig, $@" + {{ + ""slack"": + {{ + ""userAuthToken"": ""{EnvironmentVariable("userAuthToken")}"", + ""botAuthToken"": ""{EnvironmentVariable("botAuthToken")}"", + ""testChannel"": ""{EnvironmentVariable("testChannel")}"", + ""directMessageUser"": ""{EnvironmentVariable("directMessageUser")}"", + ""authCode"": ""{EnvironmentVariable("authCode")}"", + ""clientId"": ""{EnvironmentVariable("clientId")}"", + ""clientSecret"": ""{EnvironmentVariable("clientSecret")}"" + }} + }}"); + } +}); + Task("Test") - .IsDependentOn("Restore-Packages") - .IsDependentOn("Patch") + .IsDependentOn("Configure") + .IsDependentOn("ConfigureTest") .Does(() => { // AppVeyor is unable to differentiate tests from multiple frameworks @@ -110,7 +100,7 @@ Task("Test") // - replace assembly name in test report // - manualy push test result - foreach (var framework in new[] { "net452", "netcoreapp1.0"}) + foreach (var framework in new[] { "net452", "netcoreapp2.1"}) { DotNetCoreTest( testProject, @@ -153,8 +143,9 @@ Task("Pack") { Configuration = configuration, OutputDirectory = artifactsDirectory, - VersionSuffix = generatedSuffix, - ArgumentCustomization = args => args.Append("--include-symbols") + VersionSuffix = versionSuffix, + IncludeSymbols = !isReleaseBuild, + IncludeSource = !isReleaseBuild } ); From 7263fd4036f4fa93c515fa40eb4a9d342cc0aae7 Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Sat, 20 Oct 2018 23:36:31 +0700 Subject: [PATCH 3/8] Use SemVer 1 versioning to maximize compatibility --- Directory.Build.props | 10 ++-------- SlackAPI.Tests/SlackAPI.Tests.csproj | 1 - SlackAPI/SlackAPI.csproj | 3 +-- build.cake | 10 +++++----- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 5467113..4e2aa27 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,24 +1,18 @@  1.0.6 - local + local0 A Slack wrapper for direct interaction with their APIs. Inumedia - Copyright © 2018 SlackAPI en-US Inumedia - Inumedia + Inumedia https://github.com/Inumedia/SlackAPI http://choosealicense.com/licenses/mit/ true git https://github.com/Inumedia/SlackAPI - \ No newline at end of file diff --git a/SlackAPI.Tests/SlackAPI.Tests.csproj b/SlackAPI.Tests/SlackAPI.Tests.csproj index 7e702f0..bb9f54e 100644 --- a/SlackAPI.Tests/SlackAPI.Tests.csproj +++ b/SlackAPI.Tests/SlackAPI.Tests.csproj @@ -5,7 +5,6 @@ Library Full SlackAPI.Tests - SlackAPI.Tests SlackAPI.Tests diff --git a/SlackAPI/SlackAPI.csproj b/SlackAPI/SlackAPI.csproj index 6890730..607dbbd 100644 --- a/SlackAPI/SlackAPI.csproj +++ b/SlackAPI/SlackAPI.csproj @@ -4,7 +4,6 @@ net45;netstandard1.3 Full SlackAPI - SlackAPI SlackAPI @@ -12,7 +11,7 @@ - + diff --git a/build.cake b/build.cake index dfb62e8..72de8c5 100644 --- a/build.cake +++ b/build.cake @@ -8,7 +8,7 @@ var testProject = File("./SlackAPI.Tests/SlackApi.Tests.csproj"); var testConfig = File("./SlackAPI.Tests/Configuration/config.json"); var projects = new[] { mainProject, testProject }; var artifactsDirectory = Directory("./artifacts"); -var versionSuffix = "local.0"; +var versionSuffix = "local0"; var isReleaseBuild = false; Task("Clean") @@ -26,12 +26,12 @@ Task("Configure") isReleaseBuild = AppVeyor.Environment.Repository.Branch == "master" && AppVeyor.Environment.Repository.Tag.IsTag; - // If the build is a tag on master, generate a clean version (1.0.0-ci.123) - // Otherwise, append part of the SHA (1.0.0-ci.123+sha.abcdefg) - versionSuffix = $"ci.{AppVeyor.Environment.Build.Number}"; + // If the build is a tag on master, generate a clean version (1.0.0) following SemVer 1.0.0 rules + // In other cases, append metadata to identify the prerelease (1.0.0-dev123shaabcdefg) + versionSuffix = $""; if (!isReleaseBuild) { - versionSuffix += $"+sha.{AppVeyor.Environment.Repository.Commit.Id.Substring(0, 7)}"; + versionSuffix += $"dev{AppVeyor.Environment.Build.Number}sha{AppVeyor.Environment.Repository.Commit.Id.Substring(0, 8)}"; } } From b866207b51a887af987b1881ebe15ba11263743f Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Sun, 21 Oct 2018 00:29:10 +0700 Subject: [PATCH 4/8] Readded netstandard 1.6 because netstandard 1.3 cannot detect RoutinMessage in custom assemblies --- SlackAPI/SlackAPI.csproj | 8 +++++++- SlackAPI/SlackSocket.cs | 11 ++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/SlackAPI/SlackAPI.csproj b/SlackAPI/SlackAPI.csproj index 607dbbd..dfadcf7 100644 --- a/SlackAPI/SlackAPI.csproj +++ b/SlackAPI/SlackAPI.csproj @@ -1,7 +1,7 @@  - net45;netstandard1.3 + net45;netstandard1.3;netstandard1.6 Full SlackAPI SlackAPI @@ -19,6 +19,12 @@ + + + + + + $(DefineConstants);RELEASE diff --git a/SlackAPI/SlackSocket.cs b/SlackAPI/SlackSocket.cs index 6e614cf..f32d820 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 @@ -39,8 +43,13 @@ static SlackSocket() routing = new Dictionary>(); #if NET45 var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GlobalAssemblyCache == false); -#else +#elif NETSTANDARD1_6 + var assemblies = DependencyContext.Default.GetDefaultAssemblyNames().Select(Assembly.Load); +#elif NETSTANDARD1_3 var assemblies = new[] { typeof(SlackSocket).GetType().GetTypeInfo().Assembly }; +#warning Routing messages in custom assemblies are not supported with .Net Standard 1.3 +#else +#error Platform not supported #endif foreach (Assembly assembly in assemblies) { From 67caae572d1d5666ad87247de49a35d1b85e6c62 Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Sun, 21 Oct 2018 00:42:31 +0700 Subject: [PATCH 5/8] Updated Nuget denpendencies --- SlackAPI.Tests/SlackAPI.Tests.csproj | 2 +- SlackAPI/SlackAPI.csproj | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SlackAPI.Tests/SlackAPI.Tests.csproj b/SlackAPI.Tests/SlackAPI.Tests.csproj index bb9f54e..df257da 100644 --- a/SlackAPI.Tests/SlackAPI.Tests.csproj +++ b/SlackAPI.Tests/SlackAPI.Tests.csproj @@ -9,7 +9,7 @@ - + all diff --git a/SlackAPI/SlackAPI.csproj b/SlackAPI/SlackAPI.csproj index dfadcf7..b7ca772 100644 --- a/SlackAPI/SlackAPI.csproj +++ b/SlackAPI/SlackAPI.csproj @@ -9,20 +9,20 @@ - + - - - + + + - - + + From b7b15f21e038aa9aa18775fb8be3667c7c73a16b Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Sun, 21 Oct 2018 14:18:55 +0700 Subject: [PATCH 6/8] Updated versioning - Generate SemVer1 versioning for official builds (NuGet) - Generate SemVer2 versioning for dev builds (MyGet) - Add branch name to dev builds --- Directory.Build.props | 3 ++- build.cake | 60 +++++++++++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 4e2aa27..637de91 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,8 @@  1.0.6 - local0 + + dev.0+sha.0 A Slack wrapper for direct interaction with their APIs. Inumedia - Copyright © 2018 diff --git a/build.cake b/build.cake index 72de8c5..26782e1 100644 --- a/build.cake +++ b/build.cake @@ -1,14 +1,17 @@ +#tool "nuget:?package=GitVersion.CommandLine" #addin "Cake.FileHelpers" +using System.Text.RegularExpressions; + var configuration = Argument("configuration", "Release"); var target = Argument("target", "Default"); -var mainProject = File("./SlackAPI/SlackApi.csproj"); +var project = File("./SlackAPI/SlackApi.csproj"); var testProject = File("./SlackAPI.Tests/SlackApi.Tests.csproj"); var testConfig = File("./SlackAPI.Tests/Configuration/config.json"); -var projects = new[] { mainProject, testProject }; +var projects = new[] { project, testProject }; var artifactsDirectory = Directory("./artifacts"); -var versionSuffix = "local0"; +var versionSuffix = string.Empty; var isReleaseBuild = false; Task("Clean") @@ -21,18 +24,46 @@ Task("Clean") Task("Configure") .Does(() => { + var buildNumber = 0; if (AppVeyor.IsRunningOnAppVeyor) { - isReleaseBuild = AppVeyor.Environment.Repository.Branch == "master" - && AppVeyor.Environment.Repository.Tag.IsTag; + isReleaseBuild = AppVeyor.Environment.Repository.Branch == "master" && AppVeyor.Environment.Repository.Tag.IsTag; + buildNumber = AppVeyor.Environment.Build.Number; + Information("Build number is '{0}' (CI build)", buildNumber); + } + else + { + buildNumber = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + Information("Build number is '{0}' (local build)", buildNumber); + } - // If the build is a tag on master, generate a clean version (1.0.0) following SemVer 1.0.0 rules - // In other cases, append metadata to identify the prerelease (1.0.0-dev123shaabcdefg) - versionSuffix = $""; - if (!isReleaseBuild) - { - versionSuffix += $"dev{AppVeyor.Environment.Build.Number}sha{AppVeyor.Environment.Repository.Commit.Id.Substring(0, 8)}"; - } + // If the build is a tag on master, generate a clean version (1.0.0) + // following SemVer 1.0.0 rules. NuGet supports only SemVer 1.0.0 + // In other cases, generate a prerelease version (1.0.0-branch.123+sha.abcdefg) + // following SevVer 2.0.0 rules. MyGet supports SemVer 2.0.0 + if (isReleaseBuild) + { + versionSuffix = string.Empty; + } + else + { + var gitVersion = GitVersion(); + var gitBranch = (AppVeyor.IsRunningOnAppVeyor + ? AppVeyor.Environment.Repository.Branch + : gitVersion.BranchName); + gitBranch = Regex.Replace(gitBranch, @"[/\-_]", string.Empty); + gitBranch = gitBranch.Substring(0, Math.Min(10, gitBranch.Length)); + + Information("Current git branch is '{0}' (normalized)", gitBranch); + + var gitCommitId = (AppVeyor.IsRunningOnAppVeyor + ? AppVeyor.Environment.Repository.Commit.Id + : gitVersion.Sha) + .Substring(0, 8); + + Information("Current git sha is '{0}' (normalized)", gitCommitId); + + versionSuffix = $"{gitBranch}.{buildNumber}+sha.{gitCommitId}"; } var versionPrefix = XmlPeek("./Directory.Build.props", "/Project/PropertyGroup/VersionPrefix"); @@ -66,6 +97,7 @@ Task("Build") } }); + Task("ConfigureTest") .Does(() => { @@ -123,7 +155,7 @@ Task("Test") testResult, @"slackapi\.tests\.dll", "SlackAPI.Tests." + framework + ".dll", - System.Text.RegularExpressions.RegexOptions.IgnoreCase); + RegexOptions.IgnoreCase); AppVeyor.UploadTestResults(testResult, AppVeyorTestResultsType.MSTest); } @@ -138,7 +170,7 @@ Task("Pack") .Does(() => { DotNetCorePack( - mainProject, + project, new DotNetCorePackSettings { Configuration = configuration, From ba49894876ebaaedfd25d4b00c69c581f1825dcd Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Sun, 21 Oct 2018 16:21:18 +0700 Subject: [PATCH 7/8] Moved packages publishing from appveyor to cake Don't rebuild in test and publish targets --- appveyor.yml | 20 -------------------- build.cake | 44 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index cbbf860..2e0a39d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,9 +3,6 @@ image: Visual Studio 2017 pull_requests: do_not_increment_build_number: true -nuget: - disable_publish_on_pr: true - skip_branch_with_pr: true build_script: @@ -16,20 +13,3 @@ test: off artifacts: - 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 index 26782e1..82433dc 100644 --- a/build.cake +++ b/build.cake @@ -10,7 +10,7 @@ var project = File("./SlackAPI/SlackApi.csproj"); var testProject = File("./SlackAPI.Tests/SlackApi.Tests.csproj"); var testConfig = File("./SlackAPI.Tests/Configuration/config.json"); var projects = new[] { project, testProject }; -var artifactsDirectory = Directory("./artifacts"); +var artifactsDirectory = "./artifacts"; var versionSuffix = string.Empty; var isReleaseBuild = false; @@ -121,8 +121,8 @@ Task("ConfigureTest") Task("Test") - .IsDependentOn("Configure") .IsDependentOn("ConfigureTest") + .IsDependentOn("Build") .Does(() => { // AppVeyor is unable to differentiate tests from multiple frameworks @@ -139,6 +139,7 @@ Task("Test") new DotNetCoreTestSettings { Configuration = configuration, + NoBuild = true, Framework = framework, ArgumentCustomization = args => args.Append("--logger \"trx;LogFileName=result_" + framework + ".trx\""), EnvironmentVariables = new Dictionary{ @@ -163,7 +164,7 @@ Task("Test") }); -Task("Pack") +Task("Package") .IsDependentOn("Clean") .IsDependentOn("Build") .IsDependentOn("Test") @@ -174,6 +175,7 @@ Task("Pack") new DotNetCorePackSettings { Configuration = configuration, + NoBuild = true, OutputDirectory = artifactsDirectory, VersionSuffix = versionSuffix, IncludeSymbols = !isReleaseBuild, @@ -184,8 +186,42 @@ Task("Pack") }); +Task("Publish") + .IsDependentOn("Package") + .WithCriteria(() => AppVeyor.IsRunningOnAppVeyor, "Publishing is supported only from CI") + .Does(() => +{ + // Publish on Nuget if it's a release build or on MyGet for others builds + var mapping = new Dictionary + { + { true, ("NUGET_APITOKEN", "NuGet", "https://nuget.org/api/v2/package") }, + { false, ("MYGET_APITOKEN", "MyGet", "https://www.myget.org/F/slackapi/api/v2") }, + }; + + var config = mapping[isReleaseBuild]; + + var apiToken = EnvironmentVariable(config.token); + if (string.IsNullOrEmpty(apiToken)) + { + Error("{0} environment variable not found. Unable to push package on {1}", config.token, config.provider); + } + else + { + var packages = GetFiles(artifactsDirectory + "/**/*.nupkg"); + + NuGetPush(packages, new NuGetPushSettings + { + Source = config.source, + ApiKey = apiToken, + Verbosity = NuGetVerbosity.Detailed, + }); + } +}); + + Task("Default") - .IsDependentOn("Pack"); + .IsDependentOn("Package") + .IsDependentOn("Publish"); RunTarget(target); From 34a23854ae9f0529a6cc67d8df5a6d8957eb73f1 Mon Sep 17 00:00:00 2001 From: Gregoire Pailler Date: Sun, 21 Oct 2018 16:25:41 +0700 Subject: [PATCH 8/8] Readd build in all targets to ensure config.json test file is properly copied in output directory --- build.cake | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.cake b/build.cake index 82433dc..5dad9af 100644 --- a/build.cake +++ b/build.cake @@ -139,7 +139,6 @@ Task("Test") new DotNetCoreTestSettings { Configuration = configuration, - NoBuild = true, Framework = framework, ArgumentCustomization = args => args.Append("--logger \"trx;LogFileName=result_" + framework + ".trx\""), EnvironmentVariables = new Dictionary{ @@ -175,7 +174,6 @@ Task("Package") new DotNetCorePackSettings { Configuration = configuration, - NoBuild = true, OutputDirectory = artifactsDirectory, VersionSuffix = versionSuffix, IncludeSymbols = !isReleaseBuild,