Skip to content

Commit ce611c1

Browse files
authored
Support publishing package with xml files (#19787) (#20023)
* Publish package with xml files (#19787) * Refine codes
1 parent e2a56f7 commit ce611c1

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

build.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@
300300
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/NewOutputTypeIndex.ps1 -OutputFile $(RepoArtifacts)/outputtypes.json -BuildConfig $(Configuration)&quot;" Condition="'$(TargetModule)' == ''"/>
301301
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/NewHelpIndex.ps1 -OutputFile $(RepoArtifacts)/index.json -BuildConfig $(Configuration)&quot;" Condition="'$(TargetModule)' == ''"/>
302302

303-
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CleanupBuild.ps1 -BuildConfig $(Configuration)&quot;" />
303+
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CleanupBuild.ps1 -BuildConfig $(Configuration) -GenerateDocumentationFile $(GenerateDocumentationFile) &quot;" />
304304

305305
<Error Condition="'$(NuGetKey)' == ''" Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />
306306
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/PublishModules.ps1 -IsNetCore:$$(NetCore) -BuildConfig $(Configuration) -Scope $(Scope) -ApiKey $(NuGetKey) -RepositoryLocation \&quot;$(NuGetPublishingSource)\&quot;&quot; -NugetExe $(NuGetCommand)" />

tools/CleanupBuild.ps1

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,61 @@
1+
# ----------------------------------------------------------------------------------
2+
# Copyright Microsoft Corporation
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
# ----------------------------------------------------------------------------------
13+
14+
<#
15+
.SYNOPSIS
16+
Clean up unrelated files before nuget publish
17+
18+
.PARAMETER GenerateDocumentationFile
19+
Decide whether keeps XML files
20+
#>
121
[CmdletBinding()]
222
Param
323
(
424
[Parameter()]
5-
[string]$BuildConfig ="Debug"
25+
[string]$BuildConfig ="Debug",
26+
[Parameter()]
27+
[string]$GenerateDocumentationFile ="false"
28+
629
)
730

831
$output = Join-Path (Get-Item $PSScriptRoot).Parent.FullName "artifacts\$BuildConfig"
932
Write-Verbose "The output folder is set to $output"
1033
$resourceManagerPath = $output
1134

1235
$outputPaths = @($output)
36+
$resourcesFolders = @("de", "es", "fr", "it", "ja", "ko", "ru", "zh-Hans", "zh-Hant", "cs", "pl", "pt-BR", "tr")
37+
$keepItems = @("*.dll-Help.xml", "Scaffold.xml", "RoleSettings.xml", "WebRole.xml", "WorkerRole.xml")
38+
$removeItems = @("*.lastcodeanalysissucceeded", "*.dll.config", "*.pdb")
39+
if($GenerateDocumentationFile -eq "false"){
40+
Write-Verbose "Removing *.xml files from $output"
41+
$removeItems += "*.xml"
42+
}
43+
$webdependencies = @("Microsoft.Web.Hosting.dll", "Microsoft.Web.Delegation.dll", "Microsoft.Web.Administration.dll", "Microsoft.Web.Deployment.Tracing.dll")
1344

1445
foreach ($path in $outputPaths)
1546
{
1647
Write-Verbose "Removing generated NuGet folders from $path"
17-
$resourcesFolders = @("de", "es", "fr", "it", "ja", "ko", "ru", "zh-Hans", "zh-Hant", "cs", "pl", "pt-BR", "tr")
1848
Get-ChildItem -Include $resourcesFolders -Recurse -Force -Path $path | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
1949

2050
Write-Verbose "Removing autogenerated XML help files, code analysis, config files, and symbols."
21-
$exclude = @("*.dll-Help.xml", "Scaffold.xml", "RoleSettings.xml", "WebRole.xml", "WorkerRole.xml")
22-
$include = @("*.xml", "*.lastcodeanalysissucceeded", "*.dll.config", "*.pdb")
23-
Get-ChildItem -Include $include -Exclude $exclude -Recurse -Path $path | Remove-Item -Force -Recurse
51+
Get-ChildItem -Include $removeItems -Exclude $keepItems -Recurse -Path $path | Remove-Item -Force -Recurse
2452
Get-ChildItem -Recurse -Path $path -Include *.dll-Help.psd1 | Remove-Item -Force
2553

2654
Write-Verbose "Removing markdown help files and folders"
2755
Get-ChildItem -Recurse -Path $path -Include *.md | Remove-Item -Force -Confirm:$false
2856
Get-ChildItem -Directory -Include help -Recurse -Path $path | Remove-Item -Force -Recurse -Confirm:$false -ErrorAction "Ignore"
2957

3058
Write-Verbose "Removing unneeded web deployment dependencies"
31-
$webdependencies = @("Microsoft.Web.Hosting.dll", "Microsoft.Web.Delegation.dll", "Microsoft.Web.Administration.dll", "Microsoft.Web.Deployment.Tracing.dll")
3259
Get-ChildItem -Include $webdependencies -Recurse -Path $path | Remove-Item -Force
3360
}
3461

0 commit comments

Comments
 (0)