Skip to content

Commit

Permalink
Upgrade to cake 3 (fixes #56)
Browse files Browse the repository at this point in the history
  • Loading branch information
soroshsabz committed Oct 31, 2023
1 parent b9515a5 commit a9fa7e6
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 226 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "3.1.0",
"commands": [
"dotnet-cake"
]
}
}
}
2 changes: 1 addition & 1 deletion Build/BSN.Commons.Orm.EntityFramework.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>BSN.Commons.Orm.EntityFramework</id>
<version>1.10.3</version>
<version>1.11.0</version>
<authors>Seyyed Soroosh Hosseinalipour</authors>
<owners>sorosh_sabz, BSN</owners>
<license type="expression">MIT</license>
Expand Down
2 changes: 1 addition & 1 deletion Build/BSN.Commons.Users.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>BSN.Commons.Users</id>
<version>1.10.3</version>
<version>1.11.0</version>
<authors>Seyyed Soroosh Hosseinalipour</authors>
<owners>sorosh_sabz, BSN</owners>
<license type="expression">MIT</license>
Expand Down
41 changes: 20 additions & 21 deletions Build/build.cake
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
#tool "nuget:?package=coveralls.io&version=1.4.2"
#tool "nuget:?package=GitVersion.CommandLine&version=5.1.3"
#tool "nuget:?package=GitVersion.CommandLine&version=5.12.0"
#tool "nuget:?package=gitlink&version=3.1.0"
#tool "nuget:?package=GitReleaseNotes&version=0.7.1"
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.11.1"
#tool dotnet:?package=dotnet-reportgenerator-globaltool&version=5.1.19

#addin "nuget:?package=Cake.Git&version=0.21.0"
#addin "nuget:?package=Nuget.Core&version=2.14.0"
#addin "nuget:?package=Cake.Coveralls&version=0.10.1"
#addin "nuget:?package=Cake.Coverlet&version=2.3.4"
#addin "nuget:?package=Cake.Coveralls&version=1.1.0"
#addin "nuget:?package=Cake.Coverlet&version=3.0.4"
#addin "nuget:?package=Cake.Git&version=3.0.0"
#addin "nuget:?package=NuGet.Packaging&version=6.6.1"

using NuGet;
using NuGet.Packaging;

var target = Argument("target", "Default");
var artifactsDir = "./artifacts/";
var solutionPath = "../BSN.Commons.sln";
var projectName = "BSN.Commons";
var projectFolder = "../Source/";
var solutionVersion = "1.10.3";
var solutionVersion = "1.11.0";
var projects = new List<(string path, string name, string version)>
{
("BSN.Commons/", "BSN.Commons.csproj", solutionVersion),
Expand Down Expand Up @@ -59,7 +58,7 @@ Task("Clean")
);
}
CreateDirectory(artifactsDir);
DotNetCoreClean(solutionPath);
DotNetClean(solutionPath);
});


Expand Down Expand Up @@ -90,9 +89,9 @@ Task("Build")
.IsDependentOn("Restore")
.IsDependentOn("Clean")
.Does(() => {
DotNetCoreBuild(
DotNetBuild(
solutionPath,
new DotNetCoreBuildSettings
new DotNetBuildSettings
{
Configuration = configuration
}
Expand All @@ -107,7 +106,7 @@ Task("Test")
var specificCoverageResultsFileName = testProject.name + coverageResultsFileName;
var specificTestResultsFileName = testProject.name + testResultsFileName;
var settings = new DotNetCoreTestSettings {
var settings = new DotNetTestSettings {
VSTestReportPath = new FilePath(artifactsDir + specificTestResultsFileName)
};
Expand All @@ -118,7 +117,7 @@ Task("Test")
CoverletOutputName = specificCoverageResultsFileName
};
DotNetCoreTest(testFolder + testProject.path + testProject.name, settings, coverletSettings);
DotNetTest(testFolder + testProject.path + testProject.name, settings, coverletSettings);
if (AppVeyor.IsRunningOnAppVeyor)
Expand All @@ -139,7 +138,7 @@ Task("UploadCoverage")
Task("Package")
.IsDependentOn("Version")
.Does(() => {
var settings = new DotNetCorePackSettings
var settings = new DotNetPackSettings
{
OutputDirectory = artifactsDir,
NoBuild = true,
Expand Down Expand Up @@ -172,7 +171,7 @@ Task("Package")
continue;
}
DotNetCorePack(projectFolder + project.path + project.name, settings);
DotNetPack(projectFolder + project.path + project.name, settings);
}
if (AppVeyor.IsRunningOnAppVeyor)
Expand All @@ -185,7 +184,7 @@ Task("Package")
Task("Publish")
.IsDependentOn("Package")
.Does(() => {
var pushSettings = new DotNetCoreNuGetPushSettings
var pushSettings = new DotNetNuGetPushSettings
{
Source = nugetSource,
ApiKey = nugetApiKey
Expand All @@ -197,7 +196,7 @@ Task("Publish")
if(!IsNuGetPublished(pkg))
{
Information($"Publishing \"{pkg}\".");
DotNetCoreNuGetPush(pkg.FullPath, pushSettings);
DotNetNuGetPush(pkg.FullPath, pushSettings);
}
else {
Information($"Bypassing publishing \"{pkg}\" as it is already published.");
Expand All @@ -207,17 +206,17 @@ Task("Publish")
});

private bool IsNuGetPublished(FilePath packagePath) {
var package = new ZipPackage(packagePath.FullPath);
using var package = new PackageArchiveReader(new FileStream(packagePath.FullPath, FileMode.Open));

var latestPublishedVersions = NuGetList(
package.Id,
package.NuspecReader.GetId(),
new NuGetListSettings
{
Prerelease = true
}
);

return latestPublishedVersions.Any(p => package.Version.Equals(new SemanticVersion(p.Version)));
return latestPublishedVersions.Any(p => package.NuspecReader.GetVersion().Equals(p.Version));
}

private void UpdateVersion(string projectPath, string version)
Expand Down
Loading

0 comments on commit a9fa7e6

Please sign in to comment.