Skip to content

Commit ffb8993

Browse files
authored
Merge pull request #907 from pkbullock/main-macsupport
Added support for building on MacOS
2 parents 48e281e + 040b121 commit ffb8993

1 file changed

Lines changed: 45 additions & 2 deletions

File tree

docfx/docfx-build-local.ps1

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,51 @@ $runLocation = Get-Location
99
#.\report-age.ps1 -BaseDir "$($runLocation)\..\" -ReportFile "age.md"
1010

1111
Write-Host "Generating samples.json..." -ForegroundColor Cyan
12-
.\generate-samplesJson.ps1 -BaseDir "$($runLocation)\..\" -ReportFile "samples.json"
12+
$baseDir = (Resolve-Path (Join-Path $runLocation "..")).Path
13+
./generate-samplesJson.ps1 -BaseDir $baseDir -ReportFile "samples.json"
1314

1415
# Main DocFX build
1516
Write-Host "Building docfx..." -ForegroundColor Cyan
16-
docfx build docfx.json --warningsAsErrors $args
17+
if($IsMacOs){
18+
19+
<#
20+
Download DocFx and Install Mono if not already done.
21+
22+
- https://github.com/dotnet/docfx/releases/tag/v2.56.7
23+
- https://www.mono-project.com/docs/getting-started/install/mac/
24+
25+
Setup DocFx alias for MacOS
26+
27+
1. In VS Code, create a new file (e.g., `docfx.sh`) to hold the wrapper script.
28+
2. Add a wrapper to your script:
29+
30+
```bash
31+
#!/bin/zsh
32+
mono /path/to/docfx.exe "$@"
33+
```
34+
Replace `/path/to/docfx.exe` with the actual path.
35+
3. Make it executable in your terminal: `chmod +x /path/to/docfx.sh`.
36+
4. Move it to your PATH (e.g., `sudo mv /path/to/docfx.sh /usr/local/bin/docfx`).
37+
5. Restart the VS Code integrated terminal so `docfx` is available as an alias-like command without hardcoding paths in your scripts.
38+
39+
#>
40+
41+
Write-Host "Running docfx on MacOS using mono..." -ForegroundColor Cyan
42+
bash docfx build docfx.json --warningsAsErrors $args
43+
44+
}else{
45+
46+
<#
47+
Download DocFx and Install Mono if not already done.
48+
49+
- https://github.com/dotnet/docfx/releases/tag/v2.56.7
50+
- Set the PATH environment variable to include the path to docfx.exe
51+
- Open System Properties > Advanced > Environment Variables
52+
- Under System Variables, find and select the 'Path' variable, then click 'Edit'
53+
- Click 'New' and add the full path to the directory containing 'docfx.exe'
54+
- Click 'OK' to save the changes
55+
#>
56+
57+
Write-Host "Running docfx on Windows..." -ForegroundColor Cyan
58+
docfx build docfx.json --warningsAsErrors $args
59+
}

0 commit comments

Comments
 (0)