diff --git a/.gitignore b/.gitignore index 1afc7ec..7f4ebc9 100644 --- a/.gitignore +++ b/.gitignore @@ -195,3 +195,6 @@ FakesAssemblies/ # Repo tests [Tt]est[Rr]epo/ *.ide + +#Cake Artifacts dir +[Aa]rtifacts/ diff --git a/.travis.yml b/.travis.yml index ff65680..d83da49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,9 +11,9 @@ dist: trusty osx_image: xcode9.2 mono: - - 4.4.2 + - 5.12.0 -dotnet: 2.1.4 +dotnet: 2.1.400 before_install: - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 38ad4d3..1ef705a 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,8 @@ +### New in 0.19.0 (Released 2018/08/23) + +* Ported to .NET Standard 2.0 +* Updated to LibGit2Sharp 0.25.2 + ### New in 0.18.0 (Released 2018/07/04) * Bumped Cake.Core to 0.28.1 diff --git a/build.cake b/build.cake index efa3d95..8b7d897 100644 --- a/build.cake +++ b/build.cake @@ -14,8 +14,9 @@ var solutions = GetFiles("./**/*.sln"); var solutionPaths = solutions.Select(solution => solution.GetDirectory()); var releaseNotes = ParseReleaseNotes("./ReleaseNotes.md"); var version = releaseNotes.Version.ToString(); -var binDir = MakeAbsolute(Directory("./src/Cake.Git/bin/" + configuration)); +var binDir = MakeAbsolute(Directory("./src/Cake.Git/bin/" + configuration + "/net461")); var nugetRoot = "./nuget/"; +var artifactsRoot = MakeAbsolute(Directory("./artifacts/")); var semVersion = isLocalBuild ? version : string.Concat(version, "-build-", AppVeyor.Environment.Build.Number.ToString("0000")); @@ -49,10 +50,16 @@ var nuGetPackSettings = new NuGetPackSettings { Symbols = false, NoPackageAnalysis = true, Files = new NuSpecContent[0], // is set dynamically - BasePath = binDir, + BasePath = artifactsRoot, OutputDirectory = nugetRoot }; +var msBuildSettings = new DotNetCoreMSBuildSettings() + .WithProperty("Version", semVersion) + .WithProperty("AssemblyVersion", version) + .WithProperty("FileVersion", version) + .WithProperty("PackageReleaseNotes", string.Concat("\"", string.Concat(releaseNotes.Notes.ToArray()), "\"")); + Context.Tools.RegisterFile("./tools/nuget.exe"); if (!isLocalBuild) @@ -77,6 +84,15 @@ Setup(ctx => ); Information(buildStartMessage); + + if(!IsRunningOnWindows()) + { + var frameworkPathOverride = new FilePath(typeof(object).Assembly.Location).GetDirectory().FullPath + "/"; + + // Use FrameworkPathOverride when not running on Windows. + Information("Build will use FrameworkPathOverride={0} since not building on Windows.", frameworkPathOverride); + msBuildSettings.WithProperty("FrameworkPathOverride", frameworkPathOverride); + } }); Teardown(ctx => @@ -102,6 +118,9 @@ Task("Clean") Information("Cleaning {0}", nugetRoot); CleanDirectory(MakeAbsolute(Directory(nugetRoot))); + + Information("Cleaning {0}", artifactsRoot); + CleanDirectory(artifactsRoot); }); Task("Restore") @@ -111,7 +130,12 @@ Task("Restore") foreach(var solution in solutions) { Information("Restoring {0}...", solution); - NuGetRestore(solution); + DotNetCoreRestore( + solution.FullPath, + new DotNetCoreRestoreSettings { + Verbosity = DotNetCoreVerbosity.Minimal, + MSBuildSettings = msBuildSettings + }); } }); @@ -134,35 +158,64 @@ Task("Build") foreach(var solution in solutions) { Information("Building {0}", solution); - if (IsRunningOnUnix()) - { - XBuild(solution, new XBuildSettings() - .SetConfiguration(configuration) - .WithProperty("POSIX", "True") - .WithProperty("TreatWarningsAsErrors", "True") - .SetVerbosity(Verbosity.Minimal) - ); - } - else - { - MSBuild(solution, settings => - settings.SetPlatformTarget(PlatformTarget.MSIL) - .WithProperty("TreatWarningsAsErrors","true") - .WithTarget("Build") - .SetConfiguration(configuration)); - } + DotNetCoreBuild( + solution.FullPath, + new DotNetCoreBuildSettings { + Configuration = configuration, + NoRestore = true, + MSBuildSettings = msBuildSettings + }); } }); -Task("Create-NuGet-Package") +Task("Publish-Artifacts") .IsDependentOn("Build") .Does(() => { - nuGetPackSettings.Files = GetFiles(binDir + "/**/*") - .Where(file => !file.FullPath.Contains("Cake.Core.")) - .Select(file => file.FullPath.Substring(binDir.FullPath.Length+1)) - .Select(file => new NuSpecContent { Source = file, Target = "lib/net46/" + file }) - .ToArray(); + if (!DirectoryExists(artifactsRoot)) + { + CreateDirectory(artifactsRoot); + } + + DotNetCorePublish("./src/Cake.Git", new DotNetCorePublishSettings + { + NoRestore = true, + Framework = "net461", + MSBuildSettings = msBuildSettings, + OutputDirectory = artifactsRoot + "/net461" + }); + + DotNetCorePublish("./src/Cake.Git", new DotNetCorePublishSettings + { + NoRestore = true, + Framework = "netstandard2.0", + MSBuildSettings = msBuildSettings, + OutputDirectory = artifactsRoot + "/netstandard2.0" + }); +}); + + +Task("Create-NuGet-Package") + .IsDependentOn("Publish-Artifacts") + .Does(() => +{ + var native = GetFiles(artifactsRoot.FullPath + "/net461/lib/**/*"); + var cakeGit = GetFiles(artifactsRoot.FullPath + "/**/Cake.Git.dll"); + var libGit = GetFiles(artifactsRoot.FullPath + "/**/LibGit2Sharp*"); + var coreNative = GetFiles(artifactsRoot.FullPath + "/netstandard2.0/runtimes/**/*") + - GetFiles(artifactsRoot.FullPath + "/netstandard2.0/runtimes/win7-x86/**/*"); + nuGetPackSettings.Files = (native + libGit + cakeGit) + .Where(file=>!file.FullPath.Contains("Cake.Core.") && !file.FullPath.Contains("/runtimes/")) + .Select(file=>file.FullPath.Substring(artifactsRoot.FullPath.Length+1)) + .Select(file=>new NuSpecContent {Source = file, Target = "lib/" + file}) + .Union( + coreNative + .Select(file=>new NuSpecContent { + Source = file.FullPath.Substring(artifactsRoot.FullPath.Length+1), + Target = "lib/netstandard2.0/" + file.GetFilename() + }) + ) + .ToArray(); if (!DirectoryExists(nugetRoot)) { @@ -187,7 +240,18 @@ Task("Test") } Unzip(package, addinDir); - Action executeTests = ()=> CakeExecuteScript("./test.cake", new CakeSettings{ Arguments = new Dictionary{{"target", target == "Default" ? "Default-Tests" : "Local-Tests"}}}); + Action executeTests = ()=> { + CakeExecuteScript("./testnet461.cake", + new CakeSettings{ + Arguments = new Dictionary{ + {"target", target == "Default" ? "Default-Tests" : "Local-Tests"}}}); + + DotNetCoreExecute( + "./tools/Cake.CoreCLR/Cake.dll", + string.Concat("testnetstandard2.cake --target=", target == "Default" ? "Default-Tests" : "Local-Tests") + ); + }; + if (TravisCI.IsRunningOnTravisCI) { using(TravisCI.Fold("Execute-Tests")) diff --git a/src/Cake.Git/Cake.Git.csproj b/src/Cake.Git/Cake.Git.csproj index d98a218..730e584 100644 --- a/src/Cake.Git/Cake.Git.csproj +++ b/src/Cake.Git/Cake.Git.csproj @@ -1,116 +1,38 @@ - - - - + - Debug - AnyCPU - {08F0A5C3-0E9C-451D-B003-14FF73699BE1} - Library - Properties - Cake.Git - Cake.Git - v4.6 - 512 - - - + netstandard2.0;net461 + false - true full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 + bin\$(Configuration)\ bin\Debug\Cake.Git.XML pdbonly - true - bin\Release\ - TRACE - prompt - 4 + bin\$(Configuration)\ bin\Release\Cake.Git.XML + + {08F0A5C3-0E9C-451D-B003-14FF73699BE1} + - - ..\packages\Cake.Core.0.28.1\lib\net46\Cake.Core.dll - - - ..\packages\LibGit2Sharp.Portable.0.24.10\lib\net40\LibGit2Sharp.dll - True - + + All + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Properties\SolutionInfo.cs - - + LICENSE.md Always - - - - - - 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 diff --git a/src/Cake.Git/packages.config b/src/Cake.Git/packages.config deleted file mode 100644 index b4f9e99..0000000 --- a/src/Cake.Git/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index 771b5d9..675253a 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -10,9 +10,9 @@ [assembly: AssemblyDescription("Cake Git AddIn")] [assembly: AssemblyCompany("WCOM AB")] [assembly: AssemblyProduct("Cake.Git")] -[assembly: AssemblyVersion("0.18.0")] -[assembly: AssemblyFileVersion("0.18.0")] -[assembly: AssemblyInformationalVersion("0.18.0")] +[assembly: AssemblyVersion("0.19.0")] +[assembly: AssemblyFileVersion("0.19.0")] +[assembly: AssemblyInformationalVersion("0.19.0")] [assembly: AssemblyCopyright("Copyright © WCOM AB 2018")] [assembly: CLSCompliant(true)] diff --git a/test.cake b/test.cake index 0184871..3f2aa74 100644 --- a/test.cake +++ b/test.cake @@ -1,4 +1,3 @@ -#r "./tools/Addins/Cake.Git/Cake.Git/lib/net46/Cake.Git.dll" using System.Security.Cryptography; /////////////////////////////////////////////////////////////////////////////// @@ -195,7 +194,7 @@ Task("Git-HasUncommitedChanges-Dirty") .Does(() => { Information("Checking if repository has uncommited changes..."); - if (!GitHasUncommitedChanges(testInitalRepo)) + if (!GitHasUncommitedChanges(testInitalRepo)) { throw new Exception("Repository doesn't report uncommited changes."); }; @@ -206,7 +205,7 @@ Task("Git-HasUncommitedChanges-Clean") .Does(() => { Information("Checking if repository has uncommited changes..."); - if (GitHasUncommitedChanges(testInitalRepo)) + if (GitHasUncommitedChanges(testInitalRepo)) { throw new Exception("Repository reports uncommited changes after commiting all files."); }; @@ -352,12 +351,12 @@ Task("Git-Modify-Unstage") .Does(() => { Information("Unstaging added test files..."); - if (!GitHasStagedChanges(testInitalRepo)) + if (!GitHasStagedChanges(testInitalRepo)) { throw new Exception("Repository doesn't report indexed changes."); }; GitUnstageAll(testInitalRepo); - if (GitHasStagedChanges(testInitalRepo)) + if (GitHasStagedChanges(testInitalRepo)) { throw new Exception("Repository does report indexed changes."); }; @@ -466,7 +465,7 @@ Task("Git-Annotated-Tag-Apply") }); Task("Git-AllTags") - .IsDependentOn("Git-Tag") + .IsDependentOn("Git-Tag") .Does(()=> { var tags = GitTags(testInitalRepo); @@ -478,7 +477,7 @@ Task("Git-AllTags") ); Task("Git-AllTags-Annotated") - .IsDependentOn("Git-Tag-Annotated") + .IsDependentOn("Git-Tag-Annotated") .Does(()=> { var tags = GitTags(testInitalRepo); @@ -667,7 +666,7 @@ Task("Git-Current-Branch") }); Task("Git-Create-Branch") -.Does(() => +.Does(() => { var branchName = "Foo"; GitCreateBranch(testInitalRepo, branchName, true); @@ -725,7 +724,7 @@ Task("Git-Clean") .Does(() => { Information("Performing hard reset on files..."); - + if (!GitHasUntrackedFiles(testInitalRepo)) throw new InvalidOperationException("Repo contains no untracked files"); diff --git a/testnet461.cake b/testnet461.cake new file mode 100644 index 0000000..5ccf834 --- /dev/null +++ b/testnet461.cake @@ -0,0 +1,2 @@ +#r "./tools/Addins/Cake.Git/Cake.Git/lib/net461/Cake.Git.dll" +#load test.cake \ No newline at end of file diff --git a/testnetstandard2.cake b/testnetstandard2.cake new file mode 100644 index 0000000..3596390 --- /dev/null +++ b/testnetstandard2.cake @@ -0,0 +1,2 @@ +#r "./tools/Addins/Cake.Git/Cake.Git/lib/netstandard2.0/Cake.Git.dll" +#load test.cake \ No newline at end of file diff --git a/tools/packages.config b/tools/packages.config index 077c15c..5247765 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,4 +1,5 @@ +