From a7340d4d0101a9b4802af454373562c6bf6f537d Mon Sep 17 00:00:00 2001 From: Olivier Spinelli Date: Sat, 20 May 2017 16:58:06 +0200 Subject: [PATCH 1/2] Fix doc. --- CK.Core/Util.cs | 2 +- CodeCakeBuilder/Build.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CK.Core/Util.cs b/CK.Core/Util.cs index d758e308..02c0f9ed 100644 --- a/CK.Core/Util.cs +++ b/CK.Core/Util.cs @@ -310,7 +310,7 @@ public static T InterlockedSet( ref T target, TArg a, Func /// Type of the item array. /// Reference (address) of the array. Can be null. /// Item to remove. - /// The array containing the new item. Note that it may differ from the "current" items content since another thread may have already changed it. + /// The array without the item. Note that it may differ from the "current" items content since another thread may have already changed it. public static T[] InterlockedRemove( ref T[] items, T o ) { return InterlockedSet( ref items, o, ( current, item ) => diff --git a/CodeCakeBuilder/Build.cs b/CodeCakeBuilder/Build.cs index 5d6eda00..33291cc4 100644 --- a/CodeCakeBuilder/Build.cs +++ b/CodeCakeBuilder/Build.cs @@ -80,7 +80,7 @@ public Build() { Cake.Warning("GitInfo is not valid, but you choose to continue..."); } - else throw new Exception("Repository is not ready to be published."); + else if(!Cake.AppVeyor().IsRunningOnAppVeyor) throw new Exception("Repository is not ready to be published."); } if( gitInfo.IsValidRelease From 3761c4623dbecf3b517c5b4b248cc6a7d2e442aa Mon Sep 17 00:00:00 2001 From: Olivier Spinelli Date: Mon, 17 Jul 2017 11:55:07 +0200 Subject: [PATCH 2/2] Upgraded build chain. Using CK.Text 6.0.0. --- .editorconfig | 22 ++ CK.Core/CK.Core.csproj | 2 +- CodeCakeBuilder/App.config | 6 +- CodeCakeBuilder/Build.cs | 305 ++++++++---------- CodeCakeBuilder/CodeCakeBuilder.csproj | 32 +- CodeCakeBuilder/packages.config | 11 +- Tests/CK.Core.Tests/StringMatcherCoreTests.cs | 2 +- 7 files changed, 193 insertions(+), 187 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..bb34f823 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# Invenietis custom .editorconfig +# See also: https://github.com/dotnet/roslyn/blob/master/src/Workspaces/CSharp/Portable/Formatting/CSharpFormattingOptions.cs +# 20170522 + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.json] +indent_size = 2 + +[*.cs] +end_of_line = crlf +csharp_space_between_method_call_parameter_list_parentheses = true +csharp_space_between_method_declaration_parameter_list_parentheses = true +csharp_space_after_keywords_in_control_flow_statements = false +csharp_space_between_parentheses = control_flow_statements diff --git a/CK.Core/CK.Core.csproj b/CK.Core/CK.Core.csproj index 509f1905..c172378f 100644 --- a/CK.Core/CK.Core.csproj +++ b/CK.Core/CK.Core.csproj @@ -13,7 +13,7 @@ - + diff --git a/CodeCakeBuilder/App.config b/CodeCakeBuilder/App.config index 9c05822f..bae5d6d8 100644 --- a/CodeCakeBuilder/App.config +++ b/CodeCakeBuilder/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/CodeCakeBuilder/Build.cs b/CodeCakeBuilder/Build.cs index 33291cc4..c7dfb7af 100644 --- a/CodeCakeBuilder/Build.cs +++ b/CodeCakeBuilder/Build.cs @@ -21,25 +21,6 @@ namespace CodeCake { - public static class DotNetCoreRestoreSettingsExtension - { - public static T AddVersionArguments(this T @this, SimpleRepositoryInfo info, Action conf = null) where T : DotNetCoreSettings - { - if (info.IsValid) - { - var prev = @this.ArgumentCustomization; - @this.ArgumentCustomization = args => (prev?.Invoke(args) ?? args) - .Append($@"/p:CakeBuild=""true""") - .Append($@"/p:Version=""{info.NuGetVersion}""") - .Append($@"/p:AssemblyVersion=""{info.MajorMinor}.0""") - .Append($@"/p:FileVersion=""{info.FileVersion}""") - .Append($@"/p:InformationalVersion=""{info.SemVer} ({info.NuGetVersion}) - SHA1: {info.CommitSha} - CommitDate: {info.CommitDateUtc.ToString("u")}"""); - } - conf?.Invoke(@this); - return @this; - } - } - /// /// Standard build "script". /// @@ -54,174 +35,174 @@ public Build() const string solutionName = "CK-Core"; const string solutionFileName = solutionName + ".sln"; - var releasesDir = Cake.Directory("CodeCakeBuilder/Releases"); + var releasesDir = Cake.Directory( "CodeCakeBuilder/Releases" ); - var projects = Cake.ParseSolution(solutionFileName) + var projects = Cake.ParseSolution( solutionFileName ) .Projects - .Where(p => !(p is SolutionFolder) - && p.Name != "CodeCakeBuilder"); + .Where( p => !(p is SolutionFolder) + && p.Name != "CodeCakeBuilder" ); // We do not publish .Tests projects for this solution. var projectsToPublish = projects - .Where(p => !p.Path.Segments.Contains("Tests")); + .Where( p => !p.Path.Segments.Contains( "Tests" ) ); SimpleRepositoryInfo gitInfo = Cake.GetSimpleRepositoryInfo(); // Configuration is either "Debug" or "Release". string configuration = "Debug"; - Task("Check-Repository") - .Does(() => - { - if (!gitInfo.IsValid) - { - if (Cake.IsInteractiveMode() - && Cake.ReadInteractiveOption("Repository is not ready to be published. Proceed anyway?", 'Y', 'N') == 'Y') - { - Cake.Warning("GitInfo is not valid, but you choose to continue..."); - } - else if(!Cake.AppVeyor().IsRunningOnAppVeyor) throw new Exception("Repository is not ready to be published."); - } - - if( gitInfo.IsValidRelease - && (gitInfo.PreReleaseName.Length == 0 || gitInfo.PreReleaseName == "rc") ) - { - configuration = "Release"; - } - - Cake.Information("Publishing {0} projects with version={1} and configuration={2}: {3}", - projectsToPublish.Count(), - gitInfo.SemVer, - configuration, - projectsToPublish.Select(p => p.Name).Concatenate()); - }); - - Task("Unit-Testing") - .IsDependentOn("Check-Repository") - .Does(() => + Task( "Check-Repository" ) + .Does( () => { - Cake.DotNetCoreRestore(); - var testDirectories = Cake.ParseSolution(solutionFileName) - .Projects - .Where(p => p.Name.EndsWith(".Tests")) - .Select(p => p.Path.FullPath); - foreach (var test in testDirectories) + if( !gitInfo.IsValid ) { - Cake.DotNetCoreTest(test); + if( Cake.IsInteractiveMode() + && Cake.ReadInteractiveOption( "Repository is not ready to be published. Proceed anyway?", 'Y', 'N' ) == 'Y' ) + { + Cake.Warning( "GitInfo is not valid, but you choose to continue..." ); + } + else if( !Cake.AppVeyor().IsRunningOnAppVeyor ) throw new Exception( "Repository is not ready to be published." ); } - }); - Task("Clean") - .IsDependentOn("Check-Repository") - .IsDependentOn("Unit-Testing") - .Does(() => - { - Cake.CleanDirectories(projects.Select(p => p.Path.GetDirectory().Combine("bin"))); - Cake.CleanDirectories(releasesDir); - }); - - Task("Restore-NuGet-Packages-With-Version") - .WithCriteria(() => gitInfo.IsValid) - .IsDependentOn("Clean") - .Does(() => - { + if( gitInfo.IsValidRelease + && (gitInfo.PreReleaseName.Length == 0 || gitInfo.PreReleaseName == "rc") ) + { + configuration = "Release"; + } + + Cake.Information( "Publishing {0} projects with version={1} and configuration={2}: {3}", + projectsToPublish.Count(), + gitInfo.SafeSemVersion, + configuration, + projectsToPublish.Select( p => p.Name ).Concatenate() ); + } ); + + Task( "Unit-Testing" ) + .IsDependentOn( "Check-Repository" ) + .Does( () => + { + Cake.DotNetCoreRestore(); + var testDirectories = Cake.ParseSolution( solutionFileName ) + .Projects + .Where( p => p.Name.EndsWith( ".Tests" ) ) + .Select( p => p.Path.FullPath ); + foreach( var test in testDirectories ) + { + Cake.DotNetCoreTest( test ); + } + } ); + + Task( "Clean" ) + .IsDependentOn( "Check-Repository" ) + .IsDependentOn( "Unit-Testing" ) + .Does( () => + { + Cake.CleanDirectories( projects.Select( p => p.Path.GetDirectory().Combine( "bin" ) ) ); + Cake.CleanDirectories( releasesDir ); + } ); + + Task( "Restore-NuGet-Packages-With-Version" ) + .WithCriteria( () => gitInfo.IsValid ) + .IsDependentOn( "Clean" ) + .Does( () => + { // https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets - Cake.DotNetCoreRestore(new DotNetCoreRestoreSettings().AddVersionArguments(gitInfo)); - }); - - Task("Build-With-Version") - .WithCriteria(() => gitInfo.IsValid) - .IsDependentOn("Check-Repository") - .IsDependentOn("Unit-Testing") - .IsDependentOn("Clean") - .IsDependentOn("Restore-NuGet-Packages-With-Version") - .Does(() => + Cake.DotNetCoreRestore( new DotNetCoreRestoreSettings().AddVersionArguments( gitInfo ) ); + } ); + + Task( "Build-With-Version" ) + .WithCriteria( () => gitInfo.IsValid ) + .IsDependentOn( "Check-Repository" ) + .IsDependentOn( "Unit-Testing" ) + .IsDependentOn( "Clean" ) + .IsDependentOn( "Restore-NuGet-Packages-With-Version" ) + .Does( () => + { + foreach( var p in projectsToPublish ) + { + Cake.DotNetCoreBuild( p.Path.GetDirectory().FullPath, + new DotNetCoreBuildSettings().AddVersionArguments( gitInfo, s => + { + s.Configuration = configuration; + } ) ); + } + } ); + + Task( "Create-NuGet-Packages" ) + .WithCriteria( () => gitInfo.IsValid ) + .IsDependentOn( "Build-With-Version" ) + .Does( () => + { + Cake.CreateDirectory( releasesDir ); + foreach( SolutionProject p in projectsToPublish ) + { + Cake.Warning( p.Path.GetDirectory().FullPath ); + var s = new DotNetCorePackSettings(); + s.ArgumentCustomization = args => args.Append( "--include-symbols" ); + s.NoBuild = true; + s.Configuration = configuration; + s.OutputDirectory = releasesDir; + s.AddVersionArguments( gitInfo ); + Cake.DotNetCorePack( p.Path.GetDirectory().FullPath, s ); + } + } ); + + Task( "Push-NuGet-Packages" ) + .WithCriteria( () => gitInfo.IsValid ) + .IsDependentOn( "Create-NuGet-Packages" ) + .Does( () => { - foreach (var p in projectsToPublish) + IEnumerable nugetPackages = Cake.GetFiles( releasesDir.Path + "/*.nupkg" ); + if( Cake.IsInteractiveMode() ) { - Cake.DotNetCoreBuild(p.Path.GetDirectory().FullPath, - new DotNetCoreBuildSettings().AddVersionArguments(gitInfo, s => + var localFeed = Cake.FindDirectoryAbove( "LocalFeed" ); + if( localFeed != null ) + { + Cake.Information( "LocalFeed directory found: {0}", localFeed ); + if( Cake.ReadInteractiveOption( "Do you want to publish to LocalFeed?", 'Y', 'N' ) == 'Y' ) { - s.Configuration = configuration; - })); + Cake.CopyFiles( nugetPackages, localFeed ); + } + } + } + if( gitInfo.IsValidRelease ) + { + if( gitInfo.PreReleaseName == "" + || gitInfo.PreReleaseName == "prerelease" + || gitInfo.PreReleaseName == "rc" ) + { + PushNuGetPackages( "NUGET_API_KEY", "https://www.nuget.org/api/v2/package", nugetPackages ); + } + else + { + // An alpha, beta, delta, epsilon, gamma, kappa goes to invenietis-preview. + PushNuGetPackages( "MYGET_PREVIEW_API_KEY", "https://www.myget.org/F/invenietis-preview/api/v2/package", nugetPackages ); + } + } + else + { + Debug.Assert( gitInfo.IsValidCIBuild ); + PushNuGetPackages( "MYGET_CI_API_KEY", "https://www.myget.org/F/invenietis-ci/api/v2/package", nugetPackages ); + } + if( Cake.AppVeyor().IsRunningOnAppVeyor ) + { + Cake.AppVeyor().UpdateBuildVersion( gitInfo.SafeNuGetVersion ); } - }); - - Task("Create-NuGet-Packages") - .WithCriteria(() => gitInfo.IsValid) - .IsDependentOn("Build-With-Version") - .Does(() => - { - Cake.CreateDirectory(releasesDir); - foreach (SolutionProject p in projectsToPublish) - { - Cake.Warning(p.Path.GetDirectory().FullPath); - var s = new DotNetCorePackSettings(); - s.ArgumentCustomization = args => args.Append("--include-symbols"); - s.NoBuild = true; - s.Configuration = configuration; - s.OutputDirectory = releasesDir; - s.AddVersionArguments(gitInfo); - Cake.DotNetCorePack(p.Path.GetDirectory().FullPath, s); - } - }); - - Task("Push-NuGet-Packages") - .WithCriteria(() => gitInfo.IsValid) - .IsDependentOn("Create-NuGet-Packages") - .Does(() => - { - IEnumerable nugetPackages = Cake.GetFiles(releasesDir.Path + "/*.nupkg"); - if (Cake.IsInteractiveMode()) - { - var localFeed = Cake.FindDirectoryAbove("LocalFeed"); - if (localFeed != null) - { - Cake.Information("LocalFeed directory found: {0}", localFeed); - if (Cake.ReadInteractiveOption("Do you want to publish to LocalFeed?", 'Y', 'N') == 'Y') - { - Cake.CopyFiles(nugetPackages, localFeed); - } - } - } - if (gitInfo.IsValidRelease) - { - if (gitInfo.PreReleaseName == "" - || gitInfo.PreReleaseName == "prerelease" - || gitInfo.PreReleaseName == "rc") - { - PushNuGetPackages("NUGET_API_KEY", "https://www.nuget.org/api/v2/package", nugetPackages); - } - else - { - // An alpha, beta, delta, epsilon, gamma, kappa goes to invenietis-preview. - PushNuGetPackages("MYGET_PREVIEW_API_KEY", "https://www.myget.org/F/invenietis-preview/api/v2/package", nugetPackages); - } - } - else - { - Debug.Assert(gitInfo.IsValidCIBuild); - PushNuGetPackages("MYGET_CI_API_KEY", "https://www.myget.org/F/invenietis-ci/api/v2/package", nugetPackages); - } - if (Cake.AppVeyor().IsRunningOnAppVeyor) - { - Cake.AppVeyor().UpdateBuildVersion( gitInfo.NuGetVersion ); - } - }); + } ); // The Default task for this script can be set here. - Task("Default") - .IsDependentOn("Push-NuGet-Packages"); + Task( "Default" ) + .IsDependentOn( "Push-NuGet-Packages" ); } - void PushNuGetPackages(string apiKeyName, string pushUrl, IEnumerable nugetPackages) + void PushNuGetPackages( string apiKeyName, string pushUrl, IEnumerable nugetPackages ) { // Resolves the API key. - var apiKey = Cake.InteractiveEnvironmentVariable(apiKeyName); - if (string.IsNullOrEmpty(apiKey)) + var apiKey = Cake.InteractiveEnvironmentVariable( apiKeyName ); + if( string.IsNullOrEmpty( apiKey ) ) { - Cake.Information("Could not resolve {0}. Push to {1} is skipped.", apiKeyName, pushUrl); + Cake.Information( "Could not resolve {0}. Push to {1} is skipped.", apiKeyName, pushUrl ); } else { @@ -232,10 +213,10 @@ void PushNuGetPackages(string apiKeyName, string pushUrl, IEnumerable Verbosity = NuGetVerbosity.Detailed }; - foreach (var nupkg in nugetPackages.Where(p => !p.FullPath.EndsWith(".symbols.nupkg"))) + foreach( var nupkg in nugetPackages.Where( p => !p.FullPath.EndsWith( ".symbols.nupkg" ) ) ) { - Cake.Information($"Pushing '{nupkg}' to '{pushUrl}'."); - Cake.NuGetPush(nupkg, settings); + Cake.Information( $"Pushing '{nupkg}' to '{pushUrl}'." ); + Cake.NuGetPush( nupkg, settings ); } } } diff --git a/CodeCakeBuilder/CodeCakeBuilder.csproj b/CodeCakeBuilder/CodeCakeBuilder.csproj index 2455dc35..094f0b9c 100644 --- a/CodeCakeBuilder/CodeCakeBuilder.csproj +++ b/CodeCakeBuilder/CodeCakeBuilder.csproj @@ -1,6 +1,6 @@  - + Debug @@ -10,11 +10,12 @@ Properties CodeCakeBuilder CodeCakeBuilder - v4.5.1 + v4.6.1 512 true + AnyCPU @@ -36,26 +37,27 @@ 4 - - ..\packages\Cake.Common.0.19.4\lib\net45\Cake.Common.dll + + ..\packages\Cake.Common.0.21.1\lib\net45\Cake.Common.dll - - ..\packages\Cake.Core.0.19.4\lib\net45\Cake.Core.dll + + ..\packages\Cake.Core.0.21.1\lib\net45\Cake.Core.dll - - ..\packages\CK.Text.5.2.0\lib\net451\CK.Text.dll + + ..\packages\CK.Text.6.0.0\lib\net451\CK.Text.dll ..\packages\Code.Cake.0.15.0\lib\net45\Code.Cake.dll True - - ..\packages\SimpleGitVersion.Cake.0.22.0-r\lib\net45\SimpleGitVersion.Cake.dll - True + + ..\packages\CSemVer.1.0.1\lib\net461\CSemVer.dll - - ..\packages\SimpleGitVersion.Core.0.22.0-r\lib\net45\SimpleGitVersion.Core.dll - True + + ..\packages\SimpleGitVersion.Cake.0.28.0\lib\net45\SimpleGitVersion.Cake.dll + + + ..\packages\SimpleGitVersion.Core.0.28.0\lib\net45\SimpleGitVersion.Core.dll @@ -75,7 +77,7 @@ 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}. - +