Fix fsd file name
This commit is contained in:
@@ -1,71 +1,71 @@
|
|||||||
using Faithlife.Build;
|
using Faithlife.Build;
|
||||||
using NuGet.Configuration;
|
using NuGet.Configuration;
|
||||||
using NuGet.Versioning;
|
using NuGet.Versioning;
|
||||||
using static Faithlife.Build.DotNetRunner;
|
using static Faithlife.Build.DotNetRunner;
|
||||||
|
|
||||||
internal static class Build
|
internal static class Build
|
||||||
{
|
{
|
||||||
public static int Main(string[] args) => BuildRunner.Execute(args, build =>
|
public static int Main(string[] args) => BuildRunner.Execute(args, build =>
|
||||||
{
|
{
|
||||||
var artifactDirOption = build.AddOption("--artifact-dir <directory>", "Artifact directory", defaultValue: "artifacts");
|
var artifactDirOption = build.AddOption("--artifact-dir <directory>", "Artifact directory", defaultValue: "artifacts");
|
||||||
|
|
||||||
var dotNetSettings = new DotNetBuildSettings();
|
var dotNetSettings = new DotNetBuildSettings();
|
||||||
|
|
||||||
build.AddDotNetTargets(dotNetSettings);
|
build.AddDotNetTargets(dotNetSettings);
|
||||||
|
|
||||||
build.Target("deployment-package")
|
build.Target("deployment-package")
|
||||||
.DependsOn("test")
|
.DependsOn("test")
|
||||||
.Describe("Creates the deployment package")
|
.Describe("Creates the deployment package")
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
{
|
{
|
||||||
var projectPath = Path.Combine("src", "Twain.Web", "Twain.Web.csproj");
|
var projectPath = Path.Combine("src", "Twain.Web", "Twain.Web.csproj");
|
||||||
|
|
||||||
if (artifactDirOption.Value != null)
|
if (artifactDirOption.Value != null)
|
||||||
DeleteDirectory(artifactDirOption.Value);
|
DeleteDirectory(artifactDirOption.Value);
|
||||||
|
|
||||||
RunDotNet(new[]
|
RunDotNet(new[]
|
||||||
{
|
{
|
||||||
"publish", projectPath,
|
"publish", projectPath,
|
||||||
"-c", dotNetSettings.GetConfiguration(),
|
"-c", dotNetSettings.GetConfiguration(),
|
||||||
"-o", artifactDirOption.Value,
|
"-o", artifactDirOption.Value,
|
||||||
dotNetSettings.GetPlatformArg(),
|
dotNetSettings.GetPlatformArg(),
|
||||||
"--no-build",
|
"--no-build",
|
||||||
dotNetSettings.GetVerbosityArg(),
|
dotNetSettings.GetVerbosityArg(),
|
||||||
dotNetSettings.GetMaxCpuCountArg()
|
dotNetSettings.GetMaxCpuCountArg()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
build.Target("codegen")
|
build.Target("codegen")
|
||||||
.DependsOn("restore")
|
.DependsOn("restore")
|
||||||
.Describe("Generates code from the FSD")
|
.Describe("Generates code from the FSD")
|
||||||
.Does(() => CodeGen(verify: false));
|
.Does(() => CodeGen(verify: false));
|
||||||
|
|
||||||
build.Target("verify-codegen")
|
build.Target("verify-codegen")
|
||||||
.DependsOn("restore")
|
.DependsOn("restore")
|
||||||
.Describe("Ensures that the generated code is up-to-date")
|
.Describe("Ensures that the generated code is up-to-date")
|
||||||
.Does(() => CodeGen(verify: true));
|
.Does(() => CodeGen(verify: true));
|
||||||
|
|
||||||
build.Target("build")
|
build.Target("build")
|
||||||
.DependsOn("verify-codegen");
|
.DependsOn("verify-codegen");
|
||||||
|
|
||||||
void CodeGen(bool verify)
|
void CodeGen(bool verify)
|
||||||
{
|
{
|
||||||
const string slash = "/";
|
const string slash = "/";
|
||||||
const string fsdFilePath = "fsd/OapApi.v1.fsd";
|
const string fsdFilePath = "fsd/Oap.Api.v1.fsd";
|
||||||
const string clientProject = "OapApi.v1.Client";
|
const string clientProject = "OapApi.v1.Client";
|
||||||
const string webApiProject = "OapApi.v1";
|
const string webApiProject = "OapApi.v1";
|
||||||
|
|
||||||
var csharpCodeGenerator = DotNetLocalTool.Create("fsdgencsharp");
|
var csharpCodeGenerator = DotNetLocalTool.Create("fsdgencsharp");
|
||||||
var aspnetCodeGenerator = DotNetLocalTool.Create("fsdgenaspnet");
|
var aspnetCodeGenerator = DotNetLocalTool.Create("fsdgenaspnet");
|
||||||
var mdCodeGenerator = DotNetLocalTool.Create("fsdgenmd");
|
var mdCodeGenerator = DotNetLocalTool.Create("fsdgenmd");
|
||||||
var swaggerCodeGenerator = DotNetLocalTool.Create("fsdgenswagger");
|
var swaggerCodeGenerator = DotNetLocalTool.Create("fsdgenswagger");
|
||||||
|
|
||||||
var verifyOption = verify ? "--verify" : null;
|
var verifyOption = verify ? "--verify" : null;
|
||||||
|
|
||||||
csharpCodeGenerator.Run(fsdFilePath, Path.Combine("src", clientProject) + slash, "--namespace", clientProject, "--clean", "--newline", "lf", verifyOption);
|
csharpCodeGenerator.Run(fsdFilePath, Path.Combine("src", clientProject) + slash, "--namespace", clientProject, "--clean", "--newline", "lf", verifyOption);
|
||||||
aspnetCodeGenerator.Run(fsdFilePath, Path.Combine("src", "Modules", webApiProject, "Controllers"), "--namespace", $"{webApiProject}.Controllers", "--newline", "lf", verifyOption, "--target", "core");
|
aspnetCodeGenerator.Run(fsdFilePath, Path.Combine("src", "Modules", webApiProject, "Controllers"), "--namespace", $"{webApiProject}.Controllers", "--newline", "lf", verifyOption, "--target", "core");
|
||||||
mdCodeGenerator.Run(fsdFilePath, Path.Combine("docs", "api") + slash, "--clean", "--newline", "lf", verifyOption);
|
mdCodeGenerator.Run(fsdFilePath, Path.Combine("docs", "api") + slash, "--clean", "--newline", "lf", verifyOption);
|
||||||
swaggerCodeGenerator.Run(fsdFilePath, Path.Combine("src", "Modules", webApiProject, "swagger.json"), "--json", "--newline", "lf", verifyOption);
|
swaggerCodeGenerator.Run(fsdFilePath, Path.Combine("src", "Modules", webApiProject, "swagger.json"), "--json", "--newline", "lf", verifyOption);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user