When creating a VS project system or a VS project template, you can use the NuGet wizard with your project template to "pre-install" NuGet packages with your project when its created in VS via "Add New Project" dialog.
When this is done to "pre-install" DnnPackager NuGet package with a new project there is a strange error.
Theinstall.ps1 script inside the NuGet package is executed, and uses this technique to access the msbuild project, so that it can then import the additional targets to the project, however the current project is not in the LoadedProjects collection in this scenario. Therefore the install script errors.
I can only assume that NuGet is executing the install.ps1 script before the project has been fully loaded - which might make sense as its in the process of being created still perhaps.
The solution would be to amend the install.ps1 script, so that if the project is not yet in the loaded projects collection, it listens for the "ProjectAdded" event (on the ProjectCollection object) signalling that the project has finished loading, and then installs the targets!
When creating a VS project system or a VS project template, you can use the NuGet wizard with your project template to "pre-install" NuGet packages with your project when its created in VS via "Add New Project" dialog.
When this is done to "pre-install" DnnPackager NuGet package with a new project there is a strange error.
The
install.ps1
script inside the NuGet package is executed, and uses this technique to access the msbuild project, so that it can then import the additional targets to the project, however the current project is not in theLoadedProjects
collection in this scenario. Therefore the install script errors.I can only assume that NuGet is executing the install.ps1 script before the project has been fully loaded - which might make sense as its in the process of being created still perhaps.
The solution would be to amend the
install.ps1
script, so that if the project is not yet in the loaded projects collection, it listens for the "ProjectAdded" event (on theProjectCollection
object) signalling that the project has finished loading, and then installs the targets!