Skip to content

Commit effb052

Browse files
committed
fix: outputFolder path when both output and dest are specified
1 parent 7d095d6 commit effb052

File tree

8 files changed

+30
-28
lines changed

8 files changed

+30
-28
lines changed

src/Docfx.App/Config/BuildJsonConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ internal class BuildJsonConfig
4747
/// Defines the output folder of the generated build files.
4848
/// Command line --output argument prepends this value.
4949
/// </summary>
50+
[Obsolete("Use `Output` property instead. This property will be removed in a future release.")]
5051
[JsonProperty("dest")]
5152
[JsonPropertyName("dest")]
5253
public string Dest { get; set; }

src/Docfx.App/PdfBuilder.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ class Outline
5353

5454
public static Task Run(BuildJsonConfig config, string configDirectory, string? outputDirectory = null, CancellationToken cancellationToken = default)
5555
{
56-
var outputFolder = Path.GetFullPath(Path.Combine(
57-
string.IsNullOrEmpty(outputDirectory) ? Path.Combine(configDirectory, config.Output ?? "") : outputDirectory,
58-
config.Dest ?? ""));
56+
#pragma warning disable CS0618
57+
var outputFolder = Path.GetFullPath(
58+
string.IsNullOrEmpty(outputDirectory)
59+
? Path.Combine(configDirectory, config.Output ?? config.Dest ?? "")
60+
: outputDirectory);
61+
#pragma warning restore CS0618
5962

6063
Logger.LogInfo($"Searching for manifest in {outputFolder}");
6164
return CreatePdf(outputFolder, cancellationToken);

src/Docfx.App/RunBuild.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@ public static string Exec(BuildJsonConfig config, BuildOptions options, string c
2424
config.Template = ["default"];
2525
}
2626

27+
#pragma warning disable CS0618
2728
var baseDirectory = Path.GetFullPath(string.IsNullOrEmpty(configDirectory) ? Directory.GetCurrentDirectory() : configDirectory);
28-
var outputFolder = Path.GetFullPath(Path.Combine(
29-
string.IsNullOrEmpty(outputDirectory) ? Path.Combine(baseDirectory, config.Output ?? "") : outputDirectory,
30-
config.Dest ?? ""));
29+
var outputFolder = Path.GetFullPath(
30+
string.IsNullOrEmpty(outputDirectory)
31+
? Path.Combine(baseDirectory, config.Output ?? config.Dest ?? "")
32+
: outputDirectory);
33+
#pragma warning restore CS0618
3134

3235
EnvironmentContext.SetGitFeaturesDisabled(config.DisableGitFeatures);
3336
EnvironmentContext.SetBaseDirectory(baseDirectory);
3437

3538
try
3639
{
37-
var templateManager = new TemplateManager(config.Template, config.Theme, configDirectory);
40+
var templateManager = new TemplateManager(config.Template, config.Theme, baseDirectory);
3841

3942
DocumentBuilderWrapper.BuildDocument(config, options, templateManager, baseDirectory, outputFolder, null, cancellationToken);
4043

src/Docfx.Dotnet/DotnetApiCatalog.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,12 @@ private static ExtractMetadataConfig ConvertConfig(MetadataJsonItemConfig config
119119
var projects = configModel.Src;
120120
var references = configModel.References;
121121

122-
var outputFolder = Path.GetFullPath(Path.Combine(
123-
string.IsNullOrEmpty(outputDirectory) ? Path.Combine(configDirectory, configModel.Output ?? "") : outputDirectory,
124-
configModel.Dest ?? ""));
122+
#pragma warning disable CS0618
123+
var outputFolder = Path.GetFullPath(
124+
string.IsNullOrEmpty(outputDirectory)
125+
? Path.Combine(configDirectory, configModel.Output ?? configModel.Dest ?? "")
126+
: outputDirectory);
127+
#pragma warning restore CS0618
125128

126129
var expandedFiles = GlobUtility.ExpandFileMapping(EnvironmentContext.BaseDirectory, projects);
127130
var expandedReferences = GlobUtility.ExpandFileMapping(EnvironmentContext.BaseDirectory, references);

src/Docfx.Dotnet/MetadataJsonConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ internal class MetadataJsonItemConfig
113113
/// Defines the output folder of the generated metadata files.
114114
/// Command line --output argument prepends this value.
115115
/// </summary>
116+
[Obsolete("Use `Output` property instead. This property will be removed in a future release.")]
116117
[JsonProperty("dest")]
117118
[JsonPropertyName("dest")]
118119
public string Dest { get; set; }

src/docfx/Models/BuildCommand.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ public override int Execute(CommandContext context, BuildCommandOptions settings
3131

3232
internal static void MergeOptionsToConfig(BuildCommandOptions options, BuildJsonConfig config, string configDirectory)
3333
{
34-
// base directory for content from command line is current directory
35-
// e.g. C:\folder1>docfx build folder2\docfx.json --content "*.cs"
36-
// for `--content "*.cs*`, base directory should be `C:\folder1`
37-
// hence GetFullPath used below
38-
3934
// Override config file with options from command line
4035
if (options.Templates != null && options.Templates.Any())
4136
{

src/docfx/Models/MergeCommand.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ private static MergeJsonConfig ParseOptions(MergeCommandOptions options, out str
3333

3434
private static void MergeOptionsToConfig(MergeCommandOptions options, ref MergeJsonItemConfig config)
3535
{
36-
// base directory for content from command line is current directory
37-
// e.g. C:\folder1>docfx build folder2\docfx.json --content "*.cs"
38-
// for `--content "*.cs*`, base directory should be `C:\folder1`
39-
// hence GetFullPath used
4036
if (!string.IsNullOrEmpty(options.OutputFolder)) config.Destination = Path.GetFullPath(Path.Combine(options.OutputFolder, config.Destination ?? string.Empty));
4137
}
4238
}

test/docfx.Tests/MetadataCommandTest.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task TestMetadataCommandFromCSProject()
3434
File.Copy("Assets/test.cs.sample.1", sourceFile);
3535

3636
await DotnetApiCatalog.Exec(
37-
new(new MetadataJsonItemConfig { Dest = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }),
37+
new(new MetadataJsonItemConfig { Output = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }),
3838
new(), Directory.GetCurrentDirectory());
3939

4040
CheckResult();
@@ -48,7 +48,7 @@ public async Task TestMetadataCommandFromDll()
4848
File.Copy("Assets/test.dll.sample.1", dllFile);
4949

5050
await DotnetApiCatalog.Exec(
51-
new(new MetadataJsonItemConfig { Dest = _outputFolder, Src = new(new FileMappingItem(dllFile)) { Expanded = true } }),
51+
new(new MetadataJsonItemConfig { Output = _outputFolder, Src = new(new FileMappingItem(dllFile)) { Expanded = true } }),
5252
new(), Directory.GetCurrentDirectory());
5353

5454
CheckResult();
@@ -67,7 +67,7 @@ public async Task TestMetadataCommandFromMultipleFrameworksCSProject()
6767
await DotnetApiCatalog.Exec(
6868
new(new MetadataJsonItemConfig
6969
{
70-
Dest = _outputFolder,
70+
Output = _outputFolder,
7171
Src = new(new FileMappingItem(projectFile)) { Expanded = true },
7272
Properties = new() { ["TargetFramework"] = "net8.0" },
7373
}),
@@ -90,7 +90,7 @@ public async Task TestMetadataCommandFromVBProject()
9090
File.Copy("Assets/test.vb.sample.1", sourceFile);
9191

9292
await DotnetApiCatalog.Exec(
93-
new(new MetadataJsonItemConfig { Dest = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }),
93+
new(new MetadataJsonItemConfig { Output = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }),
9494
new(), Directory.GetCurrentDirectory());
9595

9696
Assert.True(File.Exists(Path.Combine(_outputFolder, ".manifest")));
@@ -154,7 +154,7 @@ public async Task TestMetadataCommandFromCSProjectWithFilterInOption()
154154
await DotnetApiCatalog.Exec(
155155
new(new MetadataJsonItemConfig
156156
{
157-
Dest = _outputFolder,
157+
Output = _outputFolder,
158158
Src = new(new FileMappingItem(projectFile)) { Expanded = true },
159159
Filter = filterFile,
160160
}),
@@ -202,7 +202,7 @@ public async Task TestMetadataCommandFromCSProjectWithDuplicateProjectReference(
202202
File.Copy("Assets/test.cs.sample.1", sourceFile);
203203

204204
await DotnetApiCatalog.Exec(
205-
new(new MetadataJsonItemConfig { Dest = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }),
205+
new(new MetadataJsonItemConfig { Output = _outputFolder, Src = new(new FileMappingItem(projectFile)) { Expanded = true } }),
206206
new(), Directory.GetCurrentDirectory());
207207

208208
CheckResult();
@@ -220,7 +220,7 @@ public async Task TestMetadataCommandFromCSProjectWithMultipleNamespaces()
220220
await DotnetApiCatalog.Exec(
221221
new(new MetadataJsonItemConfig
222222
{
223-
Dest = _outputFolder,
223+
Output = _outputFolder,
224224
Src = new(new FileMappingItem(projectFile)) { Expanded = true },
225225
NamespaceLayout = NamespaceLayout.Nested,
226226
}),
@@ -259,7 +259,7 @@ public async Task TestMetadataCommandFromCSProjectWithMultipleNamespacesWithFlat
259259
await DotnetApiCatalog.Exec(
260260
new(new MetadataJsonItemConfig
261261
{
262-
Dest = _outputFolder,
262+
Output = _outputFolder,
263263
Src = new(new FileMappingItem(projectFile)) { Expanded = true },
264264
NamespaceLayout = NamespaceLayout.Flattened,
265265
}),
@@ -298,7 +298,7 @@ public async Task TestMetadataCommandFromCSProjectWithMultipleNamespacesWithGaps
298298
await DotnetApiCatalog.Exec(
299299
new(new MetadataJsonItemConfig
300300
{
301-
Dest = _outputFolder,
301+
Output = _outputFolder,
302302
Src = new(new FileMappingItem(projectFile)) { Expanded = true },
303303
NamespaceLayout = NamespaceLayout.Nested,
304304
}),

0 commit comments

Comments
 (0)