NuGet init.ps1 is executed twice

I am following the solution found in Create a NuGet Package That Shows Update Notifications "to get a nuget package update notification.

However, the init.ps1 script is executed twice.

I removed all the code so that only the following will be in init.ps1.

param($installPath, $toolsPath, $package, $project)
if ($project -eq $null) {
$project = Get-Project
}

Write-Host "Hello, I'm running inside of init.ps1" 

      

When I close the solution and reopen it, the text appears twice in the output window.

duplicate init execution

I am using VS 2012, NuGet 2.2.31210

I checked the packages.config file and there is only one entry for my package.

Why does it work twice and is there a way to make it work only once?

Thanks Joe

+3


source to share


1 answer


In init.ps1 script Get-Project will return a random project to the project, but not the specific project where the package was installed.



Use $ projects = Get-Project -All to list the projects in the solution, loop through the projects, and search the packages.config file to check if the current project is installed.

+2


source







All Articles