Fixing Nancy.Viewengines.Razor NuGet package support for Mono on Linux

I ran into issue #1082 and I couldn't get the PostBuildEvent and CustomCommands to play nicely and consistently across all platforms.
Replacing the PostBuildEvent with an AfterBuild target seems to work everywhere (tested on VS 2012, Xamarin on Windows 8 and xbuild on Debian), but of course there are minor issues.

The solution consists of a targets file, which upon installation will automatically be added to the project file by NuGet.
To have the BuildProvider immediately available, there is a small addition to the installation script. Install.ps1 gets the active configuration, checks if it is a debug config and copies the files to the output dir.

Unfortunately this doesn't work when building with package restore. When the build starts the targets file is not available for import and so even after the package is installed the AfterBuild target is not executed.
NuGet also doesn't clean up the project file when uninstalling, which is covered by the Exists condition but still isn't very neat.

Maybe some additional tweaks are possible to get the PostBuild event to work only within visual studio, perhaps using the VisualStudioVersion property as a condition.

Any thoughts?