0

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 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.