uGet中需要PowerShell脚本才能将Package中的选

uGet中需要PowerShell脚本才能将Package中的选

本文介绍了NuGet中需要PowerShell脚本才能将Package中的选定DLL安装到VS Project中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以根据项目中的引用(例如来自.csproj文件的内容)向我解释将PowerShell中的选定DLL安装到VS项目中的PowerShell脚本中包含的详细步骤吗?

Can anyone please explain me the detailed steps to include in a PowerShell script for installing selected DLLs from a package into a VS project, based on the References in a project (say from the .csproj file)?

推荐答案

我们知道,该程序包中可以包含一个PowerShell脚本install.ps1,按照惯例,该脚本的名称和位于工具文件夹中.

As we know, there is a PowerShell script install.ps1 that can be included in the package, which is by convention named and located in tools folder.

下载NuGet程序包,例如 Newtonsoft.Json.10.0.3 .使用记事本打开软件包中的install.ps1文件,脚本应以以下行开头:

Download a NuGet package, for example, Newtonsoft.Json.10.0.3. Open the install.ps1 file in the package with notepad, the scripts should begin with the following line:

param($installPath, $toolsPath, $package, $project)

请参见在运行过程中运行PowerShell脚本NuGet软件包的安装和删除以获取更多详细信息.

See Running PowerShell scripts during NuGet package installation and removal for more detail.

然后在上述脚本之后,您可以找到以下脚本,这些脚本用于将dll从软件包安装到VS项目中:

Then after above scripts, you can find the below scripts, which used to install the dll from a package into a VS project:

$newRef = $project.Object.References.Add("PathToMyDLL")

注意:Install.ps仅在\lib\content文件夹中包含某些内容时才被调用,而不是对于仅工具"包而言.

Note: Install.ps will only be invoked if there is something in the \lib or \content folder, not for a "tools only" package.

这篇关于NuGet中需要PowerShell脚本才能将Package中的选定DLL安装到VS Project中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 03:44