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

发布后的文件:







![[激光原理与应用-93]:激光焊接检测传感器中常用的聚焦镜、分色镜、分光镜、滤波镜](https://img-blog.csdnimg.cn/direct/62dac74fe30c4685a5596e5563e23a6e.png)












