I am developing a NuGet package, including an install.ps1
script which runs during the package installation. I would like to be able to output messages from my script and also output the results of running .bat
files from within my sript.
Here is my install.ps1
:
param($installPath, $toolsPath, $package, $project)
Write-Output "Running install.ps1 for MyPkg"
Set-Location $toolsPath
.\helper.bat | Write-Output
When I install my package in Visual Studio, then I look in the Package Manager
option in the Output
page, I see:
Executing script file 'C:\Test\packages\MyPkg.1\tools\install.ps1'.
and it seems the script is working (I can tell in other ways that helper.bat
ran), but I don't see any of the output. How can I get the output working?
In order to use Source Code to debug the code form a NuGet package, we need to enable it in Visual Studio. Under the Debug menu, click on Options. First, under General, tick the option to Enable Source Link support. Next, we need to add the NuGet symbol server to the locations where Visual Studio look symbol files.
The NuGet CLI restore command downloads and installs any missing packages. The command works on projects that use either PackageReference or packages.
I could not get the output when installing from the NuGet Package Manager Dialog, I'll dig a bit later to see where it's going.
But you should be able to see it when installing from the Nuget console (Tools->Library Package Manager->Package Manager Console). The output went directly in the console. Example :
PM> uninstall-package samplepackage
hello from unninstal.ps1
Successfully removed 'samplepackage 1.0.0' from WebApplication24.
unninstal.ps1 :
param($installPath, $toolsPath, $package, $project)
Write-Host "hello from unninstal.ps1"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With