49 lines
No EOL
1.8 KiB
C#
49 lines
No EOL
1.8 KiB
C#
using Cake.Common.Tools.DotNet;
|
|
using Cake.Common.Tools.DotNet.Build;
|
|
using Cake.Common.Tools.DotNet.MSBuild;
|
|
using Cake.Core.Diagnostics;
|
|
using Cake.Frosting;
|
|
|
|
namespace Build.Tasks;
|
|
|
|
[TaskName("Build")]
|
|
[IsDependentOn(typeof(CleanTask))]
|
|
[IsDependeeOf(typeof(CopyOutputTask))]
|
|
public class BuildTask : FrostingTask<BuildContext>
|
|
{
|
|
public override void Run(BuildContext context)
|
|
{
|
|
context.Log.Information($"Building: {context.PowershellModuleCsproj}");
|
|
|
|
var buildSettings = new DotNetBuildSettings()
|
|
{
|
|
MSBuildSettings = new DotNetMSBuildSettings(),
|
|
OutputDirectory = context.PowershellModuleOutputDir,
|
|
DiagnosticOutput = true,
|
|
};
|
|
|
|
// If a build suffix is provided, use it, otherwise whatever comes from Directory.Build.props will be used.
|
|
// It's not possible to set the actual version number for a build in this project as that is purely controlled
|
|
// from individual Directory.Build.props files
|
|
if (!string.IsNullOrEmpty(context.BuildSuffix))
|
|
{
|
|
buildSettings.MSBuildSettings.VersionSuffix = context.BuildSuffix;
|
|
}
|
|
|
|
// Disable SourceLink automatic commit hash addition. Documentation about how that package work is garbage and
|
|
// this property is only mentioned in breaking changes https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/source-link
|
|
// which is pretty on par for shit like this.
|
|
if (context.DisableCommitHash)
|
|
{
|
|
buildSettings.MSBuildSettings.Properties.Add("IncludeSourceRevisionInInformationalVersion", ["false"]);
|
|
}
|
|
|
|
// /p:DebugSymbols=false
|
|
buildSettings.MSBuildSettings.Properties.Add("DebugSymbols", ["false"]);
|
|
// /p:DebugType=None
|
|
buildSettings.MSBuildSettings.Properties.Add("DebugType", ["None"]);
|
|
|
|
context.DotNetBuild(context.PowershellModuleCsproj, buildSettings);
|
|
base.Run(context);
|
|
}
|
|
} |