We have created a lot of NuGet packages. One of them is a tool, and it contains a special compiler and it is installed like a dotnet tool
. The name of the command is "PolyGen".
We used a similar mechanism to what Grpc.Tools
uses, that means we have defined .targets file inside our NugetPackage. And it works well.
But when I update my PolyGen, afterwards I have to update the dotnet tool manually with dotnet tool update
command.
But I see when the Grpc.Tools
is updated, the dotnet tool update is automatically executed. And the Package Manager console wrote the following message:
Executing nuget actions took 181,36 ms
How can we define this automatically executed command, to avoid a manual update?
Thank you guys!
NuGet creates a subfolder for each package identifier, then creates subfolders for each installed version of the package. NuGet installs package dependencies as required. This process might update package versions in the process, as described in Dependency Resolution.
Restore packages manually using Visual StudioEnable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages. In Solution Explorer, right click the solution and select Restore NuGet Packages.
You can use init.ps1
powershell script to accomplish this task. This script executing every time after package installed on targeted machines.
Just create file init.ps1
in tools/
folder of your package definition with this content:
param($installPath, $toolsPath, $package, $project)
# Write all required actions on powershell here.
But be aware of that init.ps1
also executing every time when solution opens. If you need to execute it only one time after NuGet package installation - you can insert condition parameter and store it's value inside your package installation folder (e.g. in file).
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