Skip to content
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
2 changes: 1 addition & 1 deletion .azure-pipelines/generate-modules-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ jobs:
$ModuleMapping.Keys | ForEach-Object {
$ModuleName = $_
$ModuleProjectDir = "$(System.DefaultWorkingDirectory)/src/$ModuleName/$ModuleName"
& $(System.DefaultWorkingDirectory)/tools/PackModule.ps1 -Module $ModuleName -ArtifactsLocation $(Build.ArtifactStagingDirectory)\
& $(System.DefaultWorkingDirectory)/tools/PackModule.ps1 -Module $ModuleName -ArtifactsLocation $(Build.ArtifactStagingDirectory)\ -ExcludeMarkdownDocsFromNugetPackage
}

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:
$ModuleMapping.Keys | ForEach-Object {
$ModuleName = $_
$ModuleProjectDir = "$(System.DefaultWorkingDirectory)/src/$ModuleName/$ModuleName"
& $(System.DefaultWorkingDirectory)/tools/PackModule.ps1 -Module $ModuleName -ArtifactsLocation $(Build.ArtifactStagingDirectory)\
& $(System.DefaultWorkingDirectory)/tools/PackModule.ps1 -Module $ModuleName -ArtifactsLocation $(Build.ArtifactStagingDirectory)\ -ExcludeMarkdownDocsFromNugetPackage
}

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
Expand Down
16 changes: 16 additions & 0 deletions tools/NuspecHelper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,19 @@ function Set-Dependencies(
$MetadataElement["dependencies"].AppendChild($NewDependencyElement)
}
}

<#
Remove Markdown Docs Element from the Nuspec File.
This is fixed in autorest code generator
https://github.com/Azure/autorest.powershell/blob/4e5e47e874747ce9cfbf88981538654dd2bafe4f/powershell/generators/nuspec.ts#L42
#>
function Remove-MarkdownDocsElement(
[parameter(Position=1, Mandatory=$true)]
[ValidateScript({Test-Path $_ -PathType Leaf})][string] $NuSpecFilePath){

$XmlDocument = New-Object System.Xml.XmlDocument
$XmlDocument.Load($NuSpecFilePath)
$docsNode = $XmlDocument.DocumentElement.Files.ChildNodes | Where-Object { $_.target -eq 'docs'}
$XmlDocument.DocumentElement.Files.RemoveChild($docsNode) | Out-Null
$XmlDocument.Save($NuSpecFilePath)
}
14 changes: 13 additions & 1 deletion tools/PackModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@
# Licensed under the MIT License.
Param(
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string] $Module,
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string] $ArtifactsLocation
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string] $ArtifactsLocation,
[string] $ModulePrefix="Microsoft.Graph",
[switch] $ExcludeMarkdownDocsFromNugetPackage
)
$NuspecHelperPS1 = Join-Path $PSScriptRoot "./NuspecHelper.ps1"
# Import scripts
. $NuspecHelperPS1

$LASTEXITCODE = $null
$ErrorActionPreference = "Stop"
if($PSEdition -ne "Core") {
Write-Error "This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell."
}

$ModuleProjLocation = Join-Path $PSScriptRoot "../src/$Module/$Module"
$ModuleNuspec = Join-Path $ModuleProjLocation "$ModulePrefix.$Module.nuspec"
$PackModulePS1 = Join-Path $ModuleProjLocation "/pack-module.ps1"

if (Test-Path $PackModulePS1) {
#Remove MarkDown Docs From Nuget Package
if ($ExcludeMarkdownDocsFromNugetPackage) {
Write-Information "Removing MarkDownDocs from Nuget Package..."
Remove-MarkdownDocsElement -NuSpecFilePath $ModuleNuspec
}
# Pack module
& $PackModulePS1
if($LASTEXITCODE) {
Expand Down