-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteReadme.ps1
More file actions
72 lines (55 loc) · 2.9 KB
/
WriteReadme.ps1
File metadata and controls
72 lines (55 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
param (
[string]$LibraryName,
[string]$DllName,
[string]$OutputDirectory = ".",
[switch]$IsMainProject,
[switch]$IsGithub,
[hashtable]$DllDictionary
)
# Ensure the output directory exists
if (-not (Test-Path -Path $OutputDirectory)) {
Write-Error "The specified output directory '$OutputDirectory' does not exist."
exit 1
}
# Define the content of the README.md file based on the flags
if ($IsMainProject) {
$readmeContent = @"
# ``Riverside.Win32``
---
This library offers static generations of P/Invoke for all languages using custom MSBuild tasks to build CsWin32 generations from metadata.
This 'aggregate' package contains all the Win32 P/Invoke methods and supporting types generated from the [Win32 metadata repo](https://github.com/microsoft/win32metadata).
You can use this library in any .NET language, including C#, Visual Basic, F#, IronPython, C++/CLI and others.
This library is the successor to the [PInvoke.NET](https://www.nuget.org/packages/PInvoke.Win32) project, enabling you to use Win32 P/Invoke in any .NET language.
"@
} elseif ($IsGithub -and $DllDictionary) {
$tableHeader = "| Package | Latest | Associated DLL |`n|--------|--------|--------|"
# Sort by package name
$sortedEntries = $DllDictionary.GetEnumerator() | Sort-Object Value
$tableRows = foreach ($entry in $sortedEntries) {
$key = $entry.Key
$value = $entry.Value
"| ``Riverside.Win32.$value`` | [](https://nuget.org/packages/Riverside.Win32.$value) | <kbd>$key.dll</kbd> |"
}
$tableRows = $tableRows -join "`n"
$readmeContent = @"
# ``Riverside.Win32``
---
This library offers static generations of P/Invoke for all languages using custom MSBuild tasks to build CsWin32 generations from metadata.
It uses custom PowerShell scripts and MSBuild tasks to build libraries, and is attached to a CD workflow that publishes the packages on NuGet.
You can then use the packages just as you would with CsWin32, but installing the correct package (relevant to the link library) to get the correct information.
$tableHeader
| ``Riverside.Win32`` | [](https://nuget.org/packages/Riverside.Win32) | <kbd>*</kbd> |
$tableRows
"@
} else {
$readmeContent = @"
# ``$LibraryName``
---
This package contains Win32 P/Invoke bindings for ``$DllName.dll``.
The package targets .NET Standard, meaning it can be used from any language in any .NET target framework, offering greater extensibility than CsWin32's C#-only source generator.
You can use this library in any .NET language, including C#, Visual Basic, F#, IronPython, C++/CLI and others.
"@
}
$readmePath = Join-Path -Path $OutputDirectory -ChildPath "README.md"
Set-Content -Path $readmePath -Value $readmeContent
Write-Host "README.md file has been generated successfully at '$readmePath'."