Error when trying to add OctoPack to project

Hi Paul,

I have a 3 different projects in a solution that I would like to use OctoPack with (web project, service project, and a database migrations library). However, when I try to install the OctoPack nuget package to any project I get the following errors:

PM> Install-Package OctoPack
Attempting to resolve dependency 'NuGet.CommandLine (≥ 1.6.0)'.
Successfully installed 'NuGet.CommandLine 1.6.0'.
Successfully installed 'OctoPack 1.0.94'.
Successfully added 'OctoPack 1.0.94' to Database.
Delete temporary file
Unable to find type [Microsoft.Build.Evaluation.ProjectCollection]: make sure that the assembly containing this type is loaded.
At C:\EntDev\TT Website\trunk\TT Website\packages\OctoPack.1.0.94\tools\MSBuild.psm1:26 char:61
+             @([Microsoft.Build.Evaluation.ProjectCollection] <<<< ::GlobalProjectCollection.GetLoadedProjects($path))[0]
    + CategoryInfo          : InvalidOperation: (Microsoft.Build...ojectCollection:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound
 
You cannot call a method on a null-valued expression.
At C:\EntDev\TT Website\trunk\TT Website\packages\OctoPack.1.0.94\tools\MSBuild.psm1:90 char:30
+     $buildProject.GetProperty <<<< ($PropertyName)
    + CategoryInfo          : InvalidOperation: (GetProperty:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
NuGet package restore is not enabled. Adding OctoPack from the package directory.
Installing OctoPack Targets file import into project Database
Unable to find type [Microsoft.Build.Evaluation.ProjectCollection]: make sure that the assembly containing this type is loaded.
At C:\EntDev\TT Website\trunk\TT Website\packages\OctoPack.1.0.94\tools\MSBuild.psm1:26 char:61
+             @([Microsoft.Build.Evaluation.ProjectCollection] <<<< ::GlobalProjectCollection.GetLoadedProjects($path))[0]
    + CategoryInfo          : InvalidOperation: (Microsoft.Build...ojectCollection:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound
 
The current project is:   C:\EntDev\TT Website\trunk\TT Website\Database\Database.csproj
Project parent directory: C:\EntDev\TT Website\trunk\TT Website\Database
Import will be added for: ..\packages\OctoPack.1.0.94\targets\OctoPack.targets
You cannot call a method on a null-valued expression.
At C:\EntDev\TT Website\trunk\TT Website\packages\OctoPack.1.0.94\tools\install.ps1:54 char:42
+     $target = $buildProject.Xml.AddImport <<<< ( $importFile )
    + CategoryInfo          : InvalidOperation: (AddImport:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
Import added!

This is my first time trying OctoPack so I’m not sure if I’m doing wrong or not. Is there something I’m missing?

Thanks,
Steven

Hi Steven,

Thanks for getting in touch, I’ll have to chase this one up with the NuGet team I expect. Out of interest, are you running the latest version of the NuGet VS extension? (If upgrading you may need to uninstall and then install first).

Paul

Looks like the Microsoft.Build assembly is not loaded. May need to add this somewhere in the install.ps1 script:

# Full assembly name is required
Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

This will ensure the assembly is loaded so that the install script can access the solution to add the Octopack files for package restore.

Thanks all, I’ve created an issue on GitHub to track this here:

https://github.com/OctopusDeploy/OctoPack/issues/7

Feel free to add any extra detail to that issue.

Paul