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 Answer
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)
$installPathpath to where the project is installed$toolsPathpath to the extracted tools directory$packageinformation about the currently installing package$projectreference 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.