Need PowerShell Script in NuGet to install selecte

2019-06-09 11:08发布

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)?

1条回答
Animai°情兽
2楼-- · 2019-06-09 11:29

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)?

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.

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)
  • $installPath path to where the project is installed
  • $toolsPath path to the extracted tools directory
  • $package information about the currently installing package
  • $project reference to the EnvDTE project the package is being installed into

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

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")

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

查看更多
登录 后发表回答