lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [55/62] [abbrv] lucenenet git commit: build.ps1 - Updated script to add the value of the AssemblyDescriptionAttribute as the NuGet summary
Date Tue, 04 Apr 2017 17:20:01 GMT
build.ps1 - Updated script to add the value of the AssemblyDescriptionAttribute as the NuGet
summary


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/27c00b0c
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/27c00b0c
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/27c00b0c

Branch: refs/heads/api-work
Commit: 27c00b0ce37b5845071cd27437338cfb4c4d719e
Parents: 466d3ea
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Tue Apr 4 17:58:58 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Tue Apr 4 18:33:15 2017 +0700

----------------------------------------------------------------------
 build.ps1 | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/27c00b0c/build.ps1
----------------------------------------------------------------------
diff --git a/build.ps1 b/build.ps1
index ff3bd16..6492348 100644
--- a/build.ps1
+++ b/build.ps1
@@ -297,6 +297,21 @@ function Test-Projects($projects) {
     $ErrorActionPreference = $oldPreference
 }
 
+# Gets the description from the AssemblyDescriptionAttribute
+function Get-Assembly-Description($project) {
+	#project path has a project.json file, we need the path without it
+	$dir = [System.IO.Path]::GetDirectoryName($project).TrimEnd([System.IO.Path]::DirectorySeparatorChar)
+	$projectName = [System.IO.Path]::GetFileName($dir)
+	$projectAssemblyPath = "$dir\bin\$Configuration\net451\$projectName.dll"
+
+	$assembly = [Reflection.Assembly]::ReflectionOnlyLoadFrom($projectAssemblyPath)
+	$descriptionAttributes = [reflection.customattributedata]::GetCustomAttributes($assembly)
| Where-Object {$_.AttributeType -like "System.Reflection.AssemblyDescriptionAttribute"}
+
+	if ($descriptionAttributes.Length -gt 0) {
+		$descriptionAttributes[0].ToString()-match "(?<=\[System.Reflection.AssemblyDescriptionAttribute\("")([^""]*)"
| Out-Null
+		return $Matches[0]
+	}
+}
 
 function Create-NuGetPackages($projects) {
 	
@@ -311,6 +326,14 @@ function Create-NuGetPackages($projects) {
 	foreach ($project in $projects) {
 		pushd $project.DirectoryName
 
+		# Update the packOptions.summary with the value from AssemblyDescriptionAttribute
+		$assemblyDescription = Get-Assembly-Description $project
+		Write-Host "Updating package description with '$assemblyDescription'" -ForegroundColor
Yellow
+
+		(Get-Content $project) | % {
+			$_-replace "(?<=""summary""\s*?:\s*?"")([^""]*)", $assemblyDescription
+		} | Set-Content $project -Force
+
 		Write-Host "Creating NuGet package for $project..." -ForegroundColor Magenta
 			
 		& dotnet.exe pack --configuration $Configuration --output $NuGetPackageDirectory --no-build


Mime
View raw message