如何在未安装 PowerShell 的计算机上部署 Powershell 2.0 自定义主机应用程序?
我开发了一个 Powershell 自定义主机应用程序,并希望将其部署在未安装 powershell 的计算机上。我在要部署的包中添加了“System.Management.Automation.dll”,并在我的 C# 项目中引用了它。然而,它似乎不起作用。至少,当我尝试在该计算机上构建应用程序时,它无法找到自动化程序集。有什么建议吗?
I've developed a Powershell custom host application and want to deploy it on a machine with no powershell installed. I added "System.Management.Automation.dll" in the package to deploy and have a reference to it in my C# project. However, it seems not working. At least, when I tried to build the application on that machine, it failed to locate the Automation assembly. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当你构建MSBuild或VS需要查找程序集时,它们对在哪里搜索有规则:检查项目文件中的提示路径(或VS中引用的属性)。
不过,我预计您仍然会遇到问题,PowerShell 是作为系统组件安装的,并且可能对安装程序包含的更新有更深层次的依赖。在目标系统和开发系统上安装 PowerShell 会好得多,任何其他途径都只会导致问题。
When you are building MSBuild or VS needs to find the assembly, they have rules about where to search: check the hint path in the project file (or the properties of the reference in VS).
However I expect you'll still have problems, PowerShell is installed as a system component and is likely to have much deeper dependencies on updates the installer includes. Far better to install PowerShell on both target and development systems, any other route is just going to lead to issues.
无论从技术上还是法律上来说,PowerShell 引擎都不能作为程序集重新分发。卡尔·普罗瑟(Karl Prosser)几年前就开始研究这个问题,从那以后似乎没有任何改变。
http://karlprosser.com/coder/2008/06/17/portable-powershell-v1-and-v2-side-by-side-even-on-server-core/
The PowerShell engine is not restributable as an assembly, neither technically or legally. Karl Prosser goes into this a few years ago, and nothing appears to have changed since.
http://karlprosser.com/coder/2008/06/17/portable-powershell-v1-and-v2-side-by-side-even-on-server-core/