diff --git a/src/Nuke/Azp/AzurePipelinesTasks.cs b/src/Nuke/Azp/AzurePipelinesTasks.cs index 209b0d7c..a447f6aa 100644 --- a/src/Nuke/Azp/AzurePipelinesTasks.cs +++ b/src/Nuke/Azp/AzurePipelinesTasks.cs @@ -1,5 +1,6 @@ using System.Linq.Expressions; using Nuke.Common.CI.AzurePipelines; +using Serilog; using static Nuke.Common.EnvironmentInfo; #pragma warning disable CA1822 @@ -19,6 +20,12 @@ public class AzurePipelinesTasks public static Expression> IsRunningOnAzurePipelines => () => NukeBuild.Host is AzurePipelines || Environment.GetEnvironmentVariable("LOGNAME") == "vsts"; + /// + /// Gets a value that determines if the build is not running on Azure DevOps. + /// + public static Expression> IsNotRunningOnAzurePipelines => () => + !( NukeBuild.Host is AzurePipelines || Environment.GetEnvironmentVariable("LOGNAME") == "vsts" ); + /// /// Print the azure pipelines environment /// @@ -27,25 +34,45 @@ public class AzurePipelinesTasks .Executes( () => { - Serilog.Log.Information("AGENT_ID: {AgentID}", GetVariable("AGENT_ID")); - Serilog.Log.Information("AGENT_NAME: {AgentName}", GetVariable("AGENT_NAME")); - Serilog.Log.Information("AGENT_VERSION: {AgentVersion}", GetVariable(" ")); - Serilog.Log.Information("AGENT_JOBNAME: {AgentJobName}", GetVariable("AGENT_JOBNAME")); - Serilog.Log.Information("AGENT_JOBSTATUS: {AgentJobStatus}", GetVariable("AGENT_JOBSTATUS")); - Serilog.Log.Information("AGENT_MACHINE_NAME: {AgentMachineName}", GetVariable("AGENT_MACHINE_NAME")); - Serilog.Log.Information("\n"); + Log.Information("AGENT_ID: {AgentID}", GetVariable("AGENT_ID")); + Log.Information("AGENT_NAME: {AgentName}", GetVariable("AGENT_NAME")); + Log.Information("AGENT_VERSION: {AgentVersion}", GetVariable(" ")); + Log.Information("AGENT_JOBNAME: {AgentJobName}", GetVariable("AGENT_JOBNAME")); + Log.Information("AGENT_JOBSTATUS: {AgentJobStatus}", GetVariable("AGENT_JOBSTATUS")); + Log.Information( + "AGENT_MACHINE_NAME: {AgentMachineName}", GetVariable("AGENT_MACHINE_NAME") + ); + Log.Information("\n"); - Serilog.Log.Information("BUILD_BUILDID: {BuildBuildId}", GetVariable("BUILD_BUILDID")); - Serilog.Log.Information("BUILD_BUILDNUMBER: {BuildBuildnumber}", GetVariable("BUILD_BUILDNUMBER")); - Serilog.Log.Information("BUILD_DEFINITIONNAME: {BuildDefinitionName}", GetVariable("BUILD_DEFINITIONNAME")); - Serilog.Log.Information("BUILD_DEFINITIONVERSION: {BuildDefinitionVersion}", GetVariable("BUILD_DEFINITIONVERSION")); - Serilog.Log.Information("BUILD_QUEUEDBY: {BuildQueuedBy}", GetVariable("BUILD_QUEUEDBY")); - Serilog.Log.Information("\n"); + Log.Information("BUILD_BUILDID: {BuildBuildId}", GetVariable("BUILD_BUILDID")); + Log.Information( + "BUILD_BUILDNUMBER: {BuildBuildnumber}", GetVariable("BUILD_BUILDNUMBER") + ); + Log.Information( + "BUILD_DEFINITIONNAME: {BuildDefinitionName}", GetVariable("BUILD_DEFINITIONNAME") + ); + Log.Information( + "BUILD_DEFINITIONVERSION: {BuildDefinitionVersion}", + GetVariable("BUILD_DEFINITIONVERSION") + ); + Log.Information("BUILD_QUEUEDBY: {BuildQueuedBy}", GetVariable("BUILD_QUEUEDBY")); + Log.Information("\n"); - Serilog.Log.Information("BUILD_SOURCEBRANCHNAME: {BuildSourceBranchName}", GetVariable("BUILD_SOURCEBRANCHNAME")); - Serilog.Log.Information("BUILD_SOURCEVERSION: {BuildSourceVersion}", GetVariable("BUILD_SOURCEVERSION")); - Serilog.Log.Information("BUILD_REPOSITORY_NAME: {BuildRepositoryName}", GetVariable("BUILD_REPOSITORY_NAME")); - Serilog.Log.Information("BUILD_REPOSITORY_PROVIDER: {BuildRepositoryProvider}", GetVariable("BUILD_REPOSITORY_PROVIDER")); + Log.Information( + "BUILD_SOURCEBRANCHNAME: {BuildSourceBranchName}", + GetVariable("BUILD_SOURCEBRANCHNAME") + ); + Log.Information( + "BUILD_SOURCEVERSION: {BuildSourceVersion}", GetVariable("BUILD_SOURCEVERSION") + ); + Log.Information( + "BUILD_REPOSITORY_NAME: {BuildRepositoryName}", + GetVariable("BUILD_REPOSITORY_NAME") + ); + Log.Information( + "BUILD_REPOSITORY_PROVIDER: {BuildRepositoryProvider}", + GetVariable("BUILD_REPOSITORY_PROVIDER") + ); } ); diff --git a/src/Nuke/IHaveEnableRestore.cs b/src/Nuke/IHaveEnableRestore.cs new file mode 100644 index 00000000..321c5a0e --- /dev/null +++ b/src/Nuke/IHaveEnableRestore.cs @@ -0,0 +1,15 @@ +namespace Rocket.Surgery.Nuke; + +/// +/// Defines a value whether to enable restore. +/// +public interface IHaveEnableRestore : IHave +{ + /// + /// A value indicating whether to enable restoring for a given target + /// + [Parameter("A value indicating whether to enable restoring for a given target", Name = "EnableRestore")] + public bool EnableRestore => EnvironmentInfo.GetVariable("EnableRestore") + ?? TryGetValue(() => EnableRestore) + ?? false; +} diff --git a/src/Nuke/Xamarin/ios/ICanArchiveiOS.cs b/src/Nuke/Xamarin/ios/ICanArchiveiOS.cs new file mode 100644 index 00000000..b754f5c7 --- /dev/null +++ b/src/Nuke/Xamarin/ios/ICanArchiveiOS.cs @@ -0,0 +1,42 @@ +using Nuke.Common.Tools.MSBuild; +using static Nuke.Common.Tools.MSBuild.MSBuildTasks; + +#pragma warning disable CA1304 +// ReSharper disable InconsistentNaming +// ReSharper disable once CheckNamespace +namespace Rocket.Surgery.Nuke.Xamarin +{ + /// + /// archives a binary. + /// + public interface ICanArchiveiOS : IHavePackTarget, + IHaveConfiguration, + IHaveOutputLogs, + IHaveGitVersion, + IHaveSolution, + IHaveiOSTargetPlatform, + IHaveEnableRestore, + ICan + { + /// + /// packages a binary for distribution. + /// + public Target ArchiveIpa => _ => _.OnlyWhenStatic(() => EnvironmentInfo.Platform == PlatformFamily.OSX) + .Executes( + () => + MSBuild( + settings => + settings.SetSolutionFile(Solution) + .SetRestore(EnableRestore) + .SetProperty("Platform", iOSTargetPlatform) + .SetProperty("BuildIpa", "true") + .SetProperty("ArchiveOnBuild", "true") + .SetConfiguration(Configuration) + .SetDefaultLoggers(LogsDirectory / "package.log") + .SetGitVersionEnvironment(GitVersion) + .SetAssemblyVersion(GitVersion?.AssemblySemVer) + .SetPackageVersion(GitVersion?.NuGetVersionV2) + ) + ); + } +} diff --git a/src/Nuke/Xamarin/ios/ICanPackXamariniOS.cs b/src/Nuke/Xamarin/ios/ICanPackXamariniOS.cs index abcc1312..e98ea206 100644 --- a/src/Nuke/Xamarin/ios/ICanPackXamariniOS.cs +++ b/src/Nuke/Xamarin/ios/ICanPackXamariniOS.cs @@ -1,4 +1,4 @@ -using Nuke.Common.Tools.MSBuild; +using Nuke.Common.Tools.MSBuild; using static Nuke.Common.Tools.MSBuild.MSBuildTasks; // ReSharper disable InconsistentNaming @@ -9,8 +9,8 @@ namespace Rocket.Surgery.Nuke.Xamarin; /// Xamarin iOS Pack /// public interface ICanPackXamariniOS : IHavePackTarget, - IHaveTestTarget, IHaveConfiguration, + IHaveTestTarget, IHaveOutputLogs, IHaveGitVersion, IHaveSolution, @@ -20,20 +20,21 @@ public interface ICanPackXamariniOS : IHavePackTarget, /// /// packages a binary for distribution. /// - public Target PackiPhone => _ => _ - .DependsOn(Test) - .OnlyWhenStatic(() => EnvironmentInfo.Platform == PlatformFamily.OSX) - .Executes( - () => MSBuild( - settings => settings.SetSolutionFile(Solution) - .SetProperty("Platform", iOSTargetPlatform) - .SetProperty("BuildIpa", "true") - .SetProperty("ArchiveOnBuild", "true") - .SetConfiguration(Configuration) - .SetDefaultLoggers(LogsDirectory / "package.log") - .SetGitVersionEnvironment(GitVersion) - .SetAssemblyVersion(GitVersion?.AssemblySemVer) - .SetPackageVersion(GitVersion?.NuGetVersionV2) - ) - ); + public Target PackiPhone => _ => _.DependsOn(Test) + .OnlyWhenStatic(() => EnvironmentInfo.Platform == PlatformFamily.OSX) + .Executes( + () => + MSBuild( + settings => + settings.SetSolutionFile(Solution) + .SetProperty("Platform", iOSTargetPlatform) + .SetProperty("BuildIpa", "true") + .SetProperty("ArchiveOnBuild", "true") + .SetConfiguration(Configuration) + .SetDefaultLoggers(LogsDirectory / "package.log") + .SetGitVersionEnvironment(GitVersion) + .SetAssemblyVersion(GitVersion?.AssemblySemVer) + .SetPackageVersion(GitVersion?.NuGetVersionV2) + ) + ); }