在邮政构建事件中使用时,如何将功率壳脚本的返回值分配给变量
我有一个powershell脚本,可以从dll读取汇编版本,我想将此返回值存储在变量中,我正在从后构建事件中运行ps1脚本:
当我执行脚本时:
powershell -NoProfile -ExecutionPolicy RemoteSigned -file $(SolutionDir)GetAssemblyVersion.ps1 $(TargetPath)
邮政构建事件会产生此信息:
1>1.0.8146.38525
我想将此值分配给一个变量,以便在另一个操作中能够在另一个操作中使用它,但不幸的是,它没有起作用,
A=(powershell -NoProfile -ExecutionPolicy RemoteSigned -file $(SolutionDir)GetAssemblyVersion.ps1 $(TargetPath))
我也尝试过:
A=$(powershell -NoProfile -ExecutionPolicy RemoteSigned -file $(SolutionDir)GetAssemblyVersion.ps1 $(TargetPath))
这两个解决方案都没有使用。
我的Powershell脚本是以下内容:
$strPath = $args[0]
$Assembly = [Reflection.Assembly]::Loadfile($strPath)
$AssemblyName = $Assembly.GetName()
$Assemblyversion = $AssemblyName.version
$Assemblyversion.ToString()
感谢您的评论和建议
I have a Powershell script that reads the Assembly version from a dll, I want to store this return value in a variable, I am running the ps1 script from a post-build event:
When i execute the script:
powershell -NoProfile -ExecutionPolicy RemoteSigned -file $(SolutionDir)GetAssemblyVersion.ps1 $(TargetPath)
The post build event produces this:
1>1.0.8146.38525
I want to assign this value to a variable to be able to use it later in another operation, unfortunately, it has not worked
A=(powershell -NoProfile -ExecutionPolicy RemoteSigned -file $(SolutionDir)GetAssemblyVersion.ps1 $(TargetPath))
I have also tried this:
A=$(powershell -NoProfile -ExecutionPolicy RemoteSigned -file $(SolutionDir)GetAssemblyVersion.ps1 $(TargetPath))
None of these two solutions is working.
My Powershell script is the following one:
$strPath = $args[0]
$Assembly = [Reflection.Assembly]::Loadfile($strPath)
$AssemblyName = $Assembly.GetName()
$Assemblyversion = $AssemblyName.version
$Assemblyversion.ToString()
I appreciate your comments and suggestions
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论