Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷 Updates Build Scripts #3

Merged
merged 5 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions build/funcs/Get-ModuleExports.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,32 @@ function Get-ModuleExports {
"DscResources" = @()
"FormatFiles" = @()
}
[bool] $madeGlobalVariable = $false
if (-not (Get-Variable -Name PWSHRC_FORCE_MODULES_EXPORT_UNSUPPORTED -Scope Global -ErrorAction SilentlyContinue)) {
$madeGlobalVariable = $true
Set-Variable -Name PWSHRC_FORCE_MODULES_EXPORT_UNSUPPORTED -Value $true -Scope Global -Option ReadOnly -Force
}
try {
Set-Variable -Name PWSHRC_FORCE_MODULES_EXPORT_UNSUPPORTED -Value $true -Scope Global -Option ReadOnly
[System.Management.Automation.PSModuleInfo] $moduleInfo = Import-Module -Name $Psm1Path -Force -DisableNameChecking -PassThru
if ($null -eq $moduleInfo) {
throw "Failed to import module from path '$Psm1Path'."
try {
[System.Management.Automation.PSModuleInfo] $moduleInfo = Import-Module -Name $Psm1Path -Force -DisableNameChecking -PassThru
if ($null -eq $moduleInfo) {
throw "Failed to import module from path '$Psm1Path'."
}
$results["Functions"] += @($moduleInfo.ExportedFunctions.Keys)
$results["Cmdlets"] += @($moduleInfo.ExportedCmdlets.Keys)
$results["Commands"] += @($moduleInfo.ExportedCommands.Keys)
$results["Aliases"] += @($moduleInfo.ExportedAliases.Keys)
$results["Variables"] += @($moduleInfo.ExportedVariables.Keys)
$results["DscResources"] += @($moduleInfo.ExportedDscResources)
$results["FormatFiles"] += @($moduleInfo.ExportedFormatFiles)
} finally {
if ($null -ne $moduleInfo) {
$moduleInfo | Remove-Module -Force
}
}
$results["Functions"] += @($moduleInfo.ExportedFunctions.Keys)
$results["Cmdlets"] += @($moduleInfo.ExportedCmdlets.Keys)
$results["Commands"] += @($moduleInfo.ExportedCommands.Keys)
$results["Aliases"] += @($moduleInfo.ExportedAliases.Keys)
$results["Variables"] += @($moduleInfo.ExportedVariables.Keys)
$results["DscResources"] += @($moduleInfo.ExportedDscResources)
$results["FormatFiles"] += @($moduleInfo.ExportedFormatFiles)
} finally {
Remove-Variable -Name PWSHRC_FORCE_MODULES_EXPORT_UNSUPPORTED -Scope Global -ErrorAction SilentlyContinue
if ($null -ne $moduleInfo) {
$moduleInfo | Remove-Module -Force
if ($madeGlobalVariable) {
Remove-Variable -Name PWSHRC_FORCE_MODULES_EXPORT_UNSUPPORTED -Scope Global -Force
}
}

Expand Down
27 changes: 16 additions & 11 deletions build/funcs/New-TemporaryProjectFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function New-TemporaryProjectFile {
"PackageTags" = ($PackageTags -join " ")
"PackageRequireLicenseAcceptance" = "false"
"AdditionalRestoreSources" = "`$(AdditionalRestoreSources);${psgalleryNugetFeed}"
"EnablePackInference" = "false"
}
if (-not [string]::IsNullOrWhiteSpace($ReleaseNotes)) {
$properties["PackageReleaseNotes"] = $ReleaseNotes
Expand All @@ -132,10 +133,10 @@ function New-TemporaryProjectFile {
if ($NestedRuntimePSGalleryModules) {
$itemGroupElementsForNestedRuntimePSGalleryModules += @(
$NestedRuntimePSGalleryModules | ForEach-Object {
[System.Xml.XmlElement] $element = $propertyGroupElement.OwnerDocument.CreateElement("None")
[System.Xml.XmlElement] $element = $propertyGroupElement.OwnerDocument.CreateElement("PackageFile")
$element.SetAttribute("Include", "lib${ds}$($_.id).$($_.version)${ds}**${ds}*.*")
$element.SetAttribute("Pack", "true")
$element.SetAttribute("PackagePath", "lib${ds}$($_.id).$($_.version)${ds}")
$element.SetAttribute("PackagePath", "%(RelativeDir)%(Filename)%(Extension)")
$element
}
)
Expand All @@ -149,19 +150,23 @@ function New-TemporaryProjectFile {
<PackageReference Include=`"NuGetizer`" Version=`"${nugetizerVersion}`" /> <!-- Pin to avoid SponsorLink -->
</ItemGroup>
<ItemGroup>
<None Include=`"src${ds}**${ds}*.*`" Pack=`"true`" />
<None Include=`"${LicenseFileName}`" Pack=`"true`" />
<None Include=`"${ReadmeFileName}`" Pack=`"true`" />
<None Include=`"${iconPath}`" Pack=`"true`" PackagePath=`"${iconFileName}`" />
<None Include=`"${moduleManifestFilePath}`" Pack=`"true`" PackagePath=`"${moduleManifestFilePackagePath}`" />
<None Remove=`"lib${ds}**${ds}*.*`" />
<Content Remove=`"**${ds}*.*`" />
</ItemGroup>
<ItemGroup>
<None Remove=`"**${ds}*.*`" />
</ItemGroup>
<ItemGroup>
<PackageFile Include=`"src${ds}**${ds}*.*`" Pack=`"true`" PackagePath=`"%(RelativeDir)%(Filename)%(Extension)`" />
<PackageFile Include=`"${LicenseFileName}`" Pack=`"true`" PackagePath=`"${LicenseFileName}`" />
<PackageFile Include=`"${ReadmeFileName}`" Pack=`"true`" PackagePath=`"${ReadmeFileName}`" />
<PackageFile Include=`"${iconPath}`" Pack=`"true`" PackagePath=`"${iconFileName}`" />
<PackageFile Include=`"${moduleManifestFilePath}`" Pack=`"true`" PackagePath=`"${moduleManifestFilePackagePath}`" />
$($itemGroupElementsForNestedRuntimePSGalleryModules | ForEach-Object { $_.OuterXml })
<None Remove=`"lib${ds}**${ds}README.*`" />
<None Remove=`"lib${ds}**${ds}*.nupkg`" />
</ItemGroup>
<ItemGroup>
<Content Remove=`"**/*.*`" />
<PackageFile Remove=`"**${ds}*.nupkg`" />
</ItemGroup>

</Project>"
return Get-Item -Path $projectFile
}
3 changes: 3 additions & 0 deletions build/package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ Set-StrictMode -Version Latest
-NestedRuntimePSGalleryModules $nestedRuntimePSGalleryModules
try {
dotnet pack -c Release -o "${PSScriptRoot}${ds}..${ds}out" $projectFile.FullName
if ($LASTEXITCODE -ne 0) {
throw "`dotnet pack` failed, exit code '$LASTEXITCODE'."
}
}
finally {
Remove-Item -LiteralPath $projectFile.FullName -Force
Expand Down
Loading