diff --git a/src/Docfx.App/Config/BuildJsonConfig.cs b/src/Docfx.App/Config/BuildJsonConfig.cs index c9dd2a4003a..75e6f274766 100644 --- a/src/Docfx.App/Config/BuildJsonConfig.cs +++ b/src/Docfx.App/Config/BuildJsonConfig.cs @@ -47,6 +47,7 @@ internal class BuildJsonConfig /// Defines the output folder of the generated build files. /// Command line --output argument prepends this value. /// + [Obsolete("Use `Output` property instead. This property will be removed in a future release.")] [JsonProperty("dest")] [JsonPropertyName("dest")] public string Dest { get; set; } diff --git a/src/Docfx.App/PdfBuilder.cs b/src/Docfx.App/PdfBuilder.cs index ff2a7a3a676..431b892ebe4 100644 --- a/src/Docfx.App/PdfBuilder.cs +++ b/src/Docfx.App/PdfBuilder.cs @@ -54,9 +54,12 @@ static PdfBuilder() public static Task Run(BuildJsonConfig config, string configDirectory, string? outputDirectory = null) { - var outputFolder = Path.GetFullPath(Path.Combine( - string.IsNullOrEmpty(outputDirectory) ? Path.Combine(configDirectory, config.Output ?? "") : outputDirectory, - config.Dest ?? "")); +#pragma warning disable CS0618 + var outputFolder = Path.GetFullPath( + string.IsNullOrEmpty(outputDirectory) + ? Path.Combine(configDirectory, config.Output ?? config.Dest ?? "") + : outputDirectory); +#pragma warning restore CS0618 Logger.LogInfo($"Searching for manifest in {outputFolder}"); return CreatePdf(outputFolder); diff --git a/src/Docfx.App/RunBuild.cs b/src/Docfx.App/RunBuild.cs index 33706794ffd..a1f89b44daa 100644 --- a/src/Docfx.App/RunBuild.cs +++ b/src/Docfx.App/RunBuild.cs @@ -24,17 +24,20 @@ public static string Exec(BuildJsonConfig config, BuildOptions options, string c config.Template = new ListWithStringFallback { "default" }; } +#pragma warning disable CS0618 var baseDirectory = Path.GetFullPath(string.IsNullOrEmpty(configDirectory) ? Directory.GetCurrentDirectory() : configDirectory); - var outputFolder = Path.GetFullPath(Path.Combine( - string.IsNullOrEmpty(outputDirectory) ? Path.Combine(baseDirectory, config.Output ?? "") : outputDirectory, - config.Dest ?? "")); + var outputFolder = Path.GetFullPath( + string.IsNullOrEmpty(outputDirectory) + ? Path.Combine(baseDirectory, config.Output ?? config.Dest ?? "") + : outputDirectory); +#pragma warning restore CS0618 EnvironmentContext.SetGitFeaturesDisabled(config.DisableGitFeatures); EnvironmentContext.SetBaseDirectory(baseDirectory); try { - var templateManager = new TemplateManager(config.Template, config.Theme, configDirectory); + var templateManager = new TemplateManager(config.Template, config.Theme, baseDirectory); DocumentBuilderWrapper.BuildDocument(config, options, templateManager, baseDirectory, outputFolder, null); diff --git a/src/Docfx.Dotnet/DotnetApiCatalog.cs b/src/Docfx.Dotnet/DotnetApiCatalog.cs index 948cb23cf8c..3976f31533b 100644 --- a/src/Docfx.Dotnet/DotnetApiCatalog.cs +++ b/src/Docfx.Dotnet/DotnetApiCatalog.cs @@ -141,9 +141,12 @@ private static ExtractMetadataConfig ConvertConfig(MetadataJsonItemConfig config var projects = configModel.Src; var references = configModel.References; - var outputFolder = Path.GetFullPath(Path.Combine( - string.IsNullOrEmpty(outputDirectory) ? Path.Combine(configDirectory, configModel.Output ?? "") : outputDirectory, - configModel.Dest ?? "")); +#pragma warning disable CS0618 + var outputFolder = Path.GetFullPath( + string.IsNullOrEmpty(outputDirectory) + ? Path.Combine(configDirectory, configModel.Output ?? configModel.Dest ?? "") + : outputDirectory); +#pragma warning restore CS0618 var expandedFiles = GlobUtility.ExpandFileMapping(EnvironmentContext.BaseDirectory, projects); var expandedReferences = GlobUtility.ExpandFileMapping(EnvironmentContext.BaseDirectory, references); diff --git a/src/Docfx.Dotnet/MetadataJsonConfig.cs b/src/Docfx.Dotnet/MetadataJsonConfig.cs index 1bf92029531..97b2dee043e 100644 --- a/src/Docfx.Dotnet/MetadataJsonConfig.cs +++ b/src/Docfx.Dotnet/MetadataJsonConfig.cs @@ -113,6 +113,7 @@ internal class MetadataJsonItemConfig /// Defines the output folder of the generated metadata files. /// Command line --output argument prepends this value. /// + [Obsolete("Use `Output` property instead. This property will be removed in a future release.")] [JsonProperty("dest")] [JsonPropertyName("dest")] public string Dest { get; set; } diff --git a/src/docfx/Models/BuildCommand.cs b/src/docfx/Models/BuildCommand.cs index 4dcc87189a3..4c852d4709c 100644 --- a/src/docfx/Models/BuildCommand.cs +++ b/src/docfx/Models/BuildCommand.cs @@ -31,11 +31,6 @@ public override int Execute(CommandContext context, BuildCommandOptions settings internal static void MergeOptionsToConfig(BuildCommandOptions options, BuildJsonConfig config, string configDirectory) { - // base directory for content from command line is current directory - // e.g. C:\folder1>docfx build folder2\docfx.json --content "*.cs" - // for `--content "*.cs*`, base directory should be `C:\folder1` - // hence GetFullPath used below - // Override config file with options from command line if (options.Templates != null && options.Templates.Any()) { diff --git a/src/docfx/Models/MergeCommand.cs b/src/docfx/Models/MergeCommand.cs index fa5c9624041..8f18ac880d6 100644 --- a/src/docfx/Models/MergeCommand.cs +++ b/src/docfx/Models/MergeCommand.cs @@ -33,10 +33,6 @@ private static MergeJsonConfig ParseOptions(MergeCommandOptions options, out str private static void MergeOptionsToConfig(MergeCommandOptions options, ref MergeJsonItemConfig config) { - // base directory for content from command line is current directory - // e.g. C:\folder1>docfx build folder2\docfx.json --content "*.cs" - // for `--content "*.cs*`, base directory should be `C:\folder1` - // hence GetFullPath used if (!string.IsNullOrEmpty(options.OutputFolder)) config.Destination = Path.GetFullPath(Path.Combine(options.OutputFolder, config.Destination ?? string.Empty)); } } diff --git a/test/docfx.Tests/MetadataCommandTest.cs b/test/docfx.Tests/MetadataCommandTest.cs index f83da132da0..ba90bd88750 100644 --- a/test/docfx.Tests/MetadataCommandTest.cs +++ b/test/docfx.Tests/MetadataCommandTest.cs @@ -34,7 +34,7 @@ public async Task TestMetadataCommandFromCSProject() File.Copy("Assets/test.cs.sample.1", sourceFile); await DotnetApiCatalog.Exec( - new(new MetadataJsonItemConfig { Dest = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }), + new(new MetadataJsonItemConfig { Output = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }), new(), Directory.GetCurrentDirectory()); CheckResult(); @@ -48,7 +48,7 @@ public async Task TestMetadataCommandFromDll() File.Copy("Assets/test.dll.sample.1", dllFile); await DotnetApiCatalog.Exec( - new(new MetadataJsonItemConfig { Dest = _outputFolder, Src = new(new FileMappingItem(dllFile)) { Expanded = true } }), + new(new MetadataJsonItemConfig { Output = _outputFolder, Src = new(new FileMappingItem(dllFile)) { Expanded = true } }), new(), Directory.GetCurrentDirectory()); CheckResult(); @@ -67,7 +67,7 @@ public async Task TestMetadataCommandFromMultipleFrameworksCSProject() await DotnetApiCatalog.Exec( new(new MetadataJsonItemConfig { - Dest = _outputFolder, + Output = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true }, Properties = new() { ["TargetFramework"] = "net6.0" }, }), @@ -90,7 +90,7 @@ public async Task TestMetadataCommandFromVBProject() File.Copy("Assets/test.vb.sample.1", sourceFile); await DotnetApiCatalog.Exec( - new(new MetadataJsonItemConfig { Dest = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }), + new(new MetadataJsonItemConfig { Output = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }), new(), Directory.GetCurrentDirectory()); Assert.True(File.Exists(Path.Combine(_outputFolder, ".manifest"))); @@ -154,7 +154,7 @@ public async Task TestMetadataCommandFromCSProjectWithFilterInOption() await DotnetApiCatalog.Exec( new(new MetadataJsonItemConfig { - Dest = _outputFolder, + Output = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true }, Filter = filterFile, }), @@ -202,7 +202,7 @@ public async Task TestMetadataCommandFromCSProjectWithDuplicateProjectReference( File.Copy("Assets/test.cs.sample.1", sourceFile); await DotnetApiCatalog.Exec( - new(new MetadataJsonItemConfig { Dest = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }), + new(new MetadataJsonItemConfig { Output = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }), new(), Directory.GetCurrentDirectory()); CheckResult(); @@ -220,7 +220,7 @@ public async Task TestMetadataCommandFromCSProjectWithMultipleNamespaces() await DotnetApiCatalog.Exec( new(new MetadataJsonItemConfig { - Dest = _outputFolder, + Output = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true }, NamespaceLayout = NamespaceLayout.Nested, }), @@ -259,7 +259,7 @@ public async Task TestMetadataCommandFromCSProjectWithMultipleNamespacesWithFlat await DotnetApiCatalog.Exec( new(new MetadataJsonItemConfig { - Dest = _outputFolder, + Output = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true }, NamespaceLayout = NamespaceLayout.Flattened, }), @@ -298,7 +298,7 @@ public async Task TestMetadataCommandFromCSProjectWithMultipleNamespacesWithGaps await DotnetApiCatalog.Exec( new(new MetadataJsonItemConfig { - Dest = _outputFolder, + Output = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true }, NamespaceLayout = NamespaceLayout.Nested, }),