1、安装Cake.Tool
dotnet new tool-manifest
dotnet tool install -g Cake.Tool --version 4.0.0
dotnet-cake --help
C:\Users\用户名\.config\dotnet-tools.json
2、新建项目CakeDemo(net8.0)
编写脚本: build.cake
var target = Argument("target", "Publish");
var configuration = Argument("configuration", "Release");
Task("Clean")
.WithCriteria(c => HasArgument("rebuild"))
.Does(() =>
{
CleanDirectory($"./CakeDemo/bin/{configuration}");
});
Task("Build")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetBuild("./CakeDemo/CakeDemo.csproj", new DotNetBuildSettings
{
Configuration = configuration,
});
});
Task("Publish")
.IsDependentOn("Build")
.Does(() =>
{
DotNetPublish("./CakeDemo/CakeDemo.csproj", new DotNetPublishSettings
{
Configuration = configuration,
Framework="net8.0"
});
});
RunTarget(target);
#执行
dotnet-cake build.cake
发布后的文件: