Skip to content

Commit

Permalink
Merge branch 'release/4.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertvanHorrik committed Feb 16, 2021
2 parents 985d58f + 10262c6 commit 3d74128
Show file tree
Hide file tree
Showing 44 changed files with 512 additions and 176 deletions.
10 changes: 2 additions & 8 deletions deployment/cake/apps-uwp-tasks.cake
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#pragma warning disable 1998

#l "apps-uwp-variables.cake"

#addin "nuget:?package=MagicChunks&version=2.0.0.119"
#addin "nuget:?package=Newtonsoft.Json&version=11.0.2"
#addin "nuget:?package=Microsoft.Azure.KeyVault.Core&version=1.0.0"
#addin "nuget:?package=WindowsAzure.Storage&version=9.1.1"
#addin "nuget:?package=Cake.WindowsAppStore&version=1.4.0"
#addin "nuget:?package=Cake.WindowsAppStore&version=2.0.0"

//-------------------------------------------------------------

Expand Down Expand Up @@ -212,4 +206,4 @@ public class UwpProcessor : ProcessorBase
{

}
}
}
8 changes: 2 additions & 6 deletions deployment/cake/apps-web-tasks.cake
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#pragma warning disable 1998

#l "apps-web-variables.cake"
#l "lib-octopusdeploy.cake"

#addin "nuget:?package=MagicChunks&version=2.0.0.119"
#addin "nuget:?package=Newtonsoft.Json&version=11.0.2"
#addin "nuget:?package=Microsoft.Azure.KeyVault.Core&version=1.0.0"
#addin "nuget:?package=WindowsAzure.Storage&version=9.1.1"
#addin "nuget:?package=Microsoft.Azure.KeyVault.Core&version=3.0.5"
#addin "nuget:?package=WindowsAzure.Storage&version=9.3.3"

//-------------------------------------------------------------

Expand Down
5 changes: 1 addition & 4 deletions deployment/cake/apps-wpf-tasks.cake
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#pragma warning disable 1998

#l "apps-wpf-variables.cake"

#addin "nuget:?package=MagicChunks&version=2.0.0.119"
#tool "nuget:?package=AzureStorageSync&version=2.0.0-alpha0028&prerelease"
#tool "nuget:?package=AzureStorageSync&version=2.0.0-alpha0039&prerelease"

//-------------------------------------------------------------

Expand Down
2 changes: 0 additions & 2 deletions deployment/cake/buildserver.cake
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Customize this file when using a different build server
#l "buildserver-continuaci.cake"

#addin "nuget:?package=MagicChunks&version=2.0.0.119"

using System.Runtime.InteropServices;

public interface IBuildServer
Expand Down
34 changes: 14 additions & 20 deletions deployment/cake/components-tasks.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#l "components-variables.cake"

#addin "nuget:?package=Cake.FileHelpers&version=3.0.0"

using System.Xml.Linq;

//-------------------------------------------------------------
Expand Down Expand Up @@ -141,24 +139,20 @@ public class ComponentsProcessor : ProcessorBase
{
var repositoryUrl = BuildContext.General.Repository.Url;
var repositoryCommitId = BuildContext.General.Repository.CommitId;
if (!BuildContext.General.SourceLink.IsDisabled &&
!BuildContext.General.IsLocalBuild &&
!string.IsNullOrWhiteSpace(repositoryUrl))
{
CakeContext.Information("Repository url is specified, enabling SourceLink to commit '{0}/commit/{1}'",
repositoryUrl, repositoryCommitId);

// TODO: For now we are assuming everything is git, we might need to change that in the future
// See why we set the values at https://github.com/dotnet/sourcelink/issues/159#issuecomment-427639278
msBuildSettings.WithProperty("EnableSourceLink", "true");
msBuildSettings.WithProperty("EnableSourceControlManagerQueries", "false");
msBuildSettings.WithProperty("PublishRepositoryUrl", "true");
msBuildSettings.WithProperty("RepositoryType", "git");
msBuildSettings.WithProperty("RepositoryUrl", repositoryUrl);
msBuildSettings.WithProperty("RevisionId", repositoryCommitId);

InjectSourceLinkInProjectFile(BuildContext, projectFileName);
}

CakeContext.Information("Repository url is specified, enabling SourceLink to commit '{0}/commit/{1}'",
repositoryUrl, repositoryCommitId);

// TODO: For now we are assuming everything is git, we might need to change that in the future
// See why we set the values at https://github.com/dotnet/sourcelink/issues/159#issuecomment-427639278
msBuildSettings.WithProperty("EnableSourceLink", "true");
msBuildSettings.WithProperty("EnableSourceControlManagerQueries", "false");
msBuildSettings.WithProperty("PublishRepositoryUrl", "true");
msBuildSettings.WithProperty("RepositoryType", "git");
msBuildSettings.WithProperty("RepositoryUrl", repositoryUrl);
msBuildSettings.WithProperty("RevisionId", repositoryCommitId);

InjectSourceLinkInProjectFile(BuildContext, projectFileName);
}

RunMsBuild(BuildContext, component, projectFileName, msBuildSettings);
Expand Down
43 changes: 19 additions & 24 deletions deployment/cake/dependencies-tasks.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#l "dependencies-variables.cake"

#addin "nuget:?package=Cake.FileHelpers&version=3.0.0"

using System.Xml.Linq;

//-------------------------------------------------------------
Expand Down Expand Up @@ -30,10 +28,11 @@ public class DependenciesProcessor : ProcessorBase
// is required to prevent issues with foreach
foreach (var dependency in BuildContext.Dependencies.Items.ToList())
{
if (!ShouldProcessProject(BuildContext, dependency))
{
BuildContext.Dependencies.Items.Remove(dependency);
}
// Note: dependencies should always be built
// if (!ShouldProcessProject(BuildContext, dependency))
// {
// BuildContext.Dependencies.Items.Remove(dependency);
// }
}
}

Expand Down Expand Up @@ -104,24 +103,20 @@ public class DependenciesProcessor : ProcessorBase
{
var repositoryUrl = BuildContext.General.Repository.Url;
var repositoryCommitId = BuildContext.General.Repository.CommitId;
if (!BuildContext.General.SourceLink.IsDisabled &&
!BuildContext.General.IsLocalBuild &&
!string.IsNullOrWhiteSpace(repositoryUrl))
{
CakeContext.Information("Repository url is specified, enabling SourceLink to commit '{0}/commit/{1}'",
repositoryUrl, repositoryCommitId);

// TODO: For now we are assuming everything is git, we might need to change that in the future
// See why we set the values at https://github.com/dotnet/sourcelink/issues/159#issuecomment-427639278
msBuildSettings.WithProperty("EnableSourceLink", "true");
msBuildSettings.WithProperty("EnableSourceControlManagerQueries", "false");
msBuildSettings.WithProperty("PublishRepositoryUrl", "true");
msBuildSettings.WithProperty("RepositoryType", "git");
msBuildSettings.WithProperty("RepositoryUrl", repositoryUrl);
msBuildSettings.WithProperty("RevisionId", repositoryCommitId);

InjectSourceLinkInProjectFile(BuildContext, projectFileName);
}

CakeContext.Information("Repository url is specified, enabling SourceLink to commit '{0}/commit/{1}'",
repositoryUrl, repositoryCommitId);

// TODO: For now we are assuming everything is git, we might need to change that in the future
// See why we set the values at https://github.com/dotnet/sourcelink/issues/159#issuecomment-427639278
msBuildSettings.WithProperty("EnableSourceLink", "true");
msBuildSettings.WithProperty("EnableSourceControlManagerQueries", "false");
msBuildSettings.WithProperty("PublishRepositoryUrl", "true");
msBuildSettings.WithProperty("RepositoryType", "git");
msBuildSettings.WithProperty("RepositoryUrl", repositoryUrl);
msBuildSettings.WithProperty("RevisionId", repositoryCommitId);

InjectSourceLinkInProjectFile(BuildContext, projectFileName);
}

RunMsBuild(BuildContext, dependency, projectFileName, msBuildSettings);
Expand Down
3 changes: 0 additions & 3 deletions deployment/cake/docker-tasks.cake
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#pragma warning disable 1998

#l "docker-variables.cake"
#l "lib-octopusdeploy.cake"

#addin "nuget:?package=Cake.FileHelpers&version=3.0.0"
#addin "nuget:?package=Cake.Docker&version=0.11.1"

//-------------------------------------------------------------
Expand Down
34 changes: 25 additions & 9 deletions deployment/cake/generic-tasks.cake
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#l "generic-variables.cake"

#addin "nuget:?package=MagicChunks&version=2.0.0.119"
#addin "nuget:?package=Cake.FileHelpers&version=3.0.0"
#addin "nuget:?package=Cake.DependencyCheck&version=1.2.0"
//#addin "nuget:?package=Cake.DependencyCheck&version=1.2.0"

#tool "nuget:?package=DependencyCheck.Runner.Tool&version=3.2.1&include=./**/dependency-check.sh&include=./**/dependency-check.bat"
#tool "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2018.1.3"
//#tool "nuget:?package=DependencyCheck.Runner.Tool&version=3.2.1&include=./**/dependency-check.sh&include=./**/dependency-check.bat"
//#tool "nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2018.1.3"

//-------------------------------------------------------------

Expand Down Expand Up @@ -125,13 +123,31 @@ Task("RestorePackages")
return;
}
var csharpProjects = GetFiles("./**/*.csproj");
//var csharpProjects = GetFiles("./**/*.csproj");
// var cProjects = GetFiles("./**/*.vcxproj");
var solutions = GetFiles("./**/*.sln");
var csharpProjects = new List<FilePath>();
foreach (var project in buildContext.AllProjects)
{
if (ShouldProcessProject(buildContext, project))
{
var projectFileName = GetProjectFileName(buildContext, project);
if (projectFileName.EndsWith(".csproj"))
{
Information("Adding '{0}' as C# specific project to restore", project);
csharpProjects.Add(projectFileName);
// Inject source link *before* package restore
InjectSourceLinkInProjectFile(buildContext, projectFileName);
}
}
}
var allFiles = new List<FilePath>();
allFiles.AddRange(solutions);
//allFiles.AddRange(csharpProjects);
//allFiles.AddRange(solutions);
allFiles.AddRange(csharpProjects);
// //allFiles.AddRange(cProjects);
foreach (var file in allFiles)
Expand Down
2 changes: 1 addition & 1 deletion deployment/cake/generic-variables.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#l "buildserver.cake"

#tool "nuget:?package=GitVersion.CommandLine&version=5.3.7"
#tool "nuget:?package=GitVersion.CommandLine&version=5.6.6"

//-------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion deployment/cake/github-pages-tasks.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#l "github-pages-variables.cake"

#addin "nuget:?package=Cake.Git&version=0.19.0"
#addin "nuget:?package=Cake.Git&version=1.0.0"

//-------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion deployment/cake/issuetrackers-github.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#tool "nuget:?package=gitreleasemanager&version=0.8.0"
#tool "nuget:?package=gitreleasemanager&version=0.11.0"

//-------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion deployment/cake/issuetrackers-jira.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#tool "nuget:?package=JiraCli&version=1.2.0-beta0002&prerelease"
#tool "nuget:?package=JiraCli&version=1.3.0-alpha0338&prerelease"

//-------------------------------------------------------------

Expand Down
27 changes: 24 additions & 3 deletions deployment/cake/lib-generic.cake
Original file line number Diff line number Diff line change
Expand Up @@ -516,22 +516,43 @@ private static bool ShouldProcessProject(BuildContext buildContext, string proje
return true;
}

if (ShouldBuildProject(buildContext, projectName))
{
// Always build
return true;
}

// Experimental mode where we ignore projects that are not on the deploy list when not in CI mode, but
// it can only work if they are not part of unit tests (but that should never happen)
if (buildContext.Tests.Items.Count == 0)
{
// if (buildContext.Tests.Items.Count == 0)
// {
if (checkDeployment && !ShouldDeployProject(buildContext, projectName))
{
buildContext.CakeContext.Warning("Project '{0}' should not be processed because this is not a CI build, does not contain tests and the project should not be deployed, removing from projects to process", projectName);
return false;
}
}
//}

return true;
}

//-------------------------------------------------------------

private static bool ShouldBuildProject(BuildContext buildContext, string projectName)
{
// Allow the build server to configure this via "Build[ProjectName]"
var slug = GetProjectSlug(projectName);
var keyToCheck = string.Format("Build{0}", slug);

var shouldBuild = buildContext.BuildServer.GetVariableAsBool(keyToCheck, true);

buildContext.CakeContext.Information($"Value for '{keyToCheck}': {shouldBuild}");

return shouldBuild;
}

//-------------------------------------------------------------

private static bool ShouldDeployProject(BuildContext buildContext, string projectName)
{
// Allow the build server to configure this via "Deploy[ProjectName]"
Expand Down
51 changes: 51 additions & 0 deletions deployment/cake/lib-logging.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Note: code originally comes from https://stackoverflow.com/questions/50826394/how-to-print-tool-command-line-in-cake

/// <summary>
/// Temporary sets logging verbosity.
/// </summary>
/// <example>
/// <code>
/// // Temporary sets logging verbosity to Diagnostic.
/// using(context.UseVerbosity(Verbosity.Diagnostic))
/// {
/// context.DotNetCoreBuild(project, settings);
/// }
/// </code>
/// </example>
public static VerbosityChanger UseVerbosity(this ICakeContext context, Verbosity newVerbosity) =>
new VerbosityChanger(context.Log, newVerbosity);


/// <summary>
/// Temporary sets logging verbosity to Diagnostic.
/// </summary>
/// <example>
/// <code>
/// // Temporary sets logging verbosity to Diagnostic.
/// using(context.UseDiagnosticVerbosity())
/// {
/// context.DotNetCoreBuild(project, settings);
/// }
/// </code>
/// </example>
public static VerbosityChanger UseDiagnosticVerbosity(this ICakeContext context) =>
context.UseVerbosity(Verbosity.Diagnostic);

/// <summary>
/// Cake log verbosity changer.
/// Restores old verbosity on Dispose.
/// </summary>
public class VerbosityChanger : IDisposable
{
ICakeLog _log;
Verbosity _oldVerbosity;

public VerbosityChanger(ICakeLog log, Verbosity newVerbosity)
{
_log = log;
_oldVerbosity = log.Verbosity;
_log.Verbosity = newVerbosity;
}

public void Dispose() => _log.Verbosity = _oldVerbosity;
}
Loading

0 comments on commit 3d74128

Please sign in to comment.