-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.ps1
93 lines (79 loc) · 3.05 KB
/
build.ps1
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Param(
[Parameter(Mandatory = $false)]
[ValidateSet("Debug","Release")]
[string]$BuildConfiguration = "Release"
)
$moduleDir = Join-Path -path $PSScriptRoot -ChildPath "Intersight.PowerShell"
$solutionPath = Join-Path -Path $PSScriptRoot -ChildPath "src\Intersight.PowerShell.sln"
Write-host "Build the Intersight.PowerShell module."
try
{
dotnet build $solutionPath -o $moduleDir -c $BuildConfiguration
}
catch{
throw $_.Exception
Exit 1
}
#Check for whether build success or failure
if ($LASTEXITCODE -ne 0){
Write-Host "Build failed, fix the code and re-run."
Exit $LASTEXITCODE
}
# run the unit test
try
{
dotnet test ./src/Intersight.PowerShellTest/Intersight.PowerShellTest.csproj --logger trx
}
catch{
throw $_.Exception
Exit 1
}
if ($LASTEXITCODE -ne 0){
Write-Host "Unit Test failed, fix the code and re-run."
Exit $LASTEXITCODE
}
# Import the dll and get the list of cmdlet available in the module
Import-Module -Name $moduleDir\Intersight.PowerShell.dll
$commandList = Get-Command -Module Intersight.PowerShell
Remove-module -Name Intersight.PowerShell
Write-Host "Generate the Moudle manifest file."
$manifestParam = @{
Path = Join-Path -Path $moduleDir -ChildPath "Intersight.PowerShell.psd1"
RootModule = "Intersight.PowerShell.dll"
Guid = "41ce1a70-9c4b-489f-a153-12fe49b7fe62"
Author = "Cisco Systems"
CompanyName = "Cisco Systems"
ModuleVersion = "1.0.11.2024101709"
Copyright = "(c) 2023 Cisco Systems, Inc. All rights reserved."
LicenseUri = "https://www.apache.org/licenses/LICENSE-2.0.txt"
ProjectUri = "https://github.com/CiscoDevNet/intersight-powershell"
CompatiblePSEditions = "Core"
Tag = @('PSEdition_Core','Windows','Linux','MacOSX','Intersight','IntersightCmdlets')
PowerShellVersion = "7.3.3"
CmdletsToExport = $commandList
Description = "Intersight Powershell module provides the cmdlets to manage, analyze, and automate the IT infrastructure in Intersight."
ReleaseNotes = "Intersight.PowerShell - Version 1.0.11.2024101709
Changelog:-
https://github.com/CiscoDevNet/intersight-powershell/blob/master/CHANGELOG.md
GettingStarted:-
https://github.com/CiscoDevNet/intersight-powershell/blob/master/GettingStarted.md
Examples:-
https://github.com/CiscoDevNet/intersight-powershell/tree/master/examples
Intersight Help Center:
https://www.intersight.com/help
"
}
$manifestResult = New-ModuleManifest @manifestParam
Write-Host "Module manifest created successfully." -ForegroundColor green
Write-Host "Copy module help file to $moduleDir"
if (Test-Path -Path $moduleDir -PathType Container){
$externalHelpFilePath = Join-Path -Path $PSScriptRoot -ChildPath "externalHelp\Intersight.PowerShell.dll-Help.xml"
if (Test-Path -Path $externalHelpFilePath ){
Copy-Item -Path $externalHelpFilePath -Destination $moduleDir
Write-Host "Successfully copied the help file to $moduleDir."
}
}
else{
Write-Host "Module directory $moduleDir does not exist, cannot copy external help file."
}
Write-Host "Intersight.PowerShell module build completed."