惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
IT之家
IT之家
博客园 - 【当耐特】
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Hugging Face - Blog
Hugging Face - Blog
I
InfoQ
B
Blog RSS Feed
腾讯CDC
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
雷峰网
雷峰网
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
D
DataBreaches.Net
The Cloudflare Blog
V
V2EX
S
SegmentFault 最新的问题

博客园 - VAllen

ConcurrentNativeQueue<T>:一个使用 .NET 实现的零 GC 压力的无锁 MPSC 原生队列 在DOS环境下升级BMC带外管理模块固件的另类办法 .NET 响应式编程 System.Reactive 系列文章(三):Subscribe 和 IDisposable 的深入理解 .NET 响应式编程 System.Reactive 系列文章(二):深入理解 IObservable<T> 和 IObserver<T> .NET 响应式编程 System.Reactive 系列文章(一):基础概念 分析基于ASP.NET Core Kernel的gRPC服务在不同.NET版本的不同部署方式的不同线程池下的性能表现 从Windows 11 23H2升级至24H2后,Git操作提示文件所有权错误的3种有效解决方案 在Windows平台使用源码编译和安装PyTorch3D指定版本 【一天一点.NET小知识】运用向量Vector<T>加速求和计算 为什么不推荐使用Linq? 在System身份运行的.NET程序中以指定的用户身份启动可交互式进程 如何使用csproj构建C#源代码组件NuGet包? 如何更改.NET中的默认时区? 高性能版本的零内存分配LikeString函数(ZeroMemAllocLikeOperator) 在.NET Core,除了VB的LikeString,还有其它方法吗?(四种LikeString实现分享) 在 Windows 11 中为 WSL2 启用 Systemd 以及修复ping不通和DNS无法解析等的问题 在Linux平台下使用.NET Core访问Access数据库读取mdb文件数据 Windows 11 + Samsung 980 踩坑:在 LocalDB 15.0 实例启动期间出错: 无法启动 SQL Server 进程(附赠 查询指定日期范围内的前1000条SQL执行记录) SQL Server 2000 创建角色,登陆用户,安全用户,批量授予权限
在PowerShell脚本中获取程序集文件属性的指定元数据特性的方...
VAllen · 2022-04-26 · via 博客园 - VAllen
<#
	.SYNOPSIS
		获取程序集文件属性的指定元数据特性
	
	.DESCRIPTION
		获取程序集文件属性的指定元数据特性
	
	.PARAMETER filePath
		程序集文件路径
	
	.PARAMETER name
		元数据名称
	
	.EXAMPLE
				PS C:\> Get-AssemblyMetadata -filePath 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.4\System.Text.Json.dll' -name 'RepositoryUrl'
				https://github.com/dotnet/runtime
	
	.NOTES
		Additional information about the function.
#>
function Get-AssemblyMetadata
{
	[OutputType([string])]
	param
	(
		[Parameter(Mandatory = $true, HelpMessage = '程序集文件路径')]
		[Alias('p')]
		[string]$filePath,
		[Parameter(Mandatory = $true, HelpMessage = '元数据名称')]
		[Alias('n')]
		[string]$name
	)
	
	if (-not (Test-Path $filePath))
	{
		return ""
	}
	
	## $asm = [System.Reflection.Assembly]::LoadFile($filePath)
	## $data = $asm.CustomAttributes

	$buffer = [System.IO.File]::ReadAllBytes($filePath)
	$asm = [System.Reflection.Assembly]::Load($buffer)
	$data = [System.Reflection.CustomAttributeData]::GetCustomAttributes($asm)
	foreach ($attr in $data)
	{
		if ($attr.AttributeType.Name -eq 'AssemblyMetadataAttribute' -and $attr.ConstructorArguments.Count -eq 2)
		{
			$nameArg = $attr.ConstructorArguments[0];
			$valueArg = $attr.ConstructorArguments[1];
			if ($nameArg.Value -eq $name)
			{
				return $valueArg.Value
			}
		}
	}
	
	return ""
}

使用示例

PS C:\> Get-AssemblyMetadata -filePath 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.4\System.Text.Json.dll' -name 'RepositoryUrl'
https://github.com/dotnet/runtime