2

I created a simple NuGet package that includes an Init.ps1 script in the Tools folder. The script starts as follows:

param($installPath, $toolsPath, $package, $project)

$postBuildEvent = $project.Properties.Item("PostBuildEvent").Value

When installing the package in a Visual Studio 2012 project I get an error on $project.Properties.Item, because $project.Properties is null: "You cannot call a method on a null-valued expression". I checked if $project.Properties is null and it is.

Question is, why it is null. I just try to alter the post build event (like described here). Does anyone have clues?

Edit: If the code is inside Install.ps1 it works. It seems that the project properties are not available when first installing a package.

Community
  • 1
  • 1
Jürgen Bayer
  • 2,993
  • 3
  • 26
  • 51

1 Answers1

0

The parameter list for init.ps1 is:

param($installPath, $toolsPath, $package)

init.ps1 does not have the $project parameter because it is executed at the solution level and is not dependent on project.

See here for more information: http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package

CarllDev
  • 1,294
  • 2
  • 19
  • 34