Quantcast
Channel: WE MOVED to github.com/nuget. This site is not monitored!
Viewing all articles
Browse latest Browse all 7612

New Post: Project unavailable error while unloading project from Install.ps1

$
0
0

In my Install.ps1 I’ve managed to add a post build event to my project file using the msbuild api:

param($installPath, $toolsPath, $package, $project)
#save the project file first - this commits the changes made by nuget before this  script runs.
$project.Save()

Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
$buildProject = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName) | Select-Object -First 1

$buildEventText = 'REM Some post build event'

$propertyGroup = $buildProject.Xml.AddPropertyGroup()

$propertyGroup.AddProperty("PostBuildEvent",$buildEventText)

$project.Save() #persists the changes

Now, this doesn’t show up in VS until the project is unloaded and reloaded. I’ve found this somewhat arcane way of doing this:

$shortpath = $dte.Solution.Properties.Item("Name").Value + "\" + $project.Name

#following GUID = Constants.vsWindowKindSolutionExplorer
#magic 1 = vsUISelectionType.vsUISelectionTypeSelect
$dte.Windows.Item("{3AE79031-E1BC-11D0-8F78-00A0C9110057}").Activate()
$dte.ActiveWindow.Object.GetItem($shortpath).Select(1)
$dte.ExecuteCommand("Project.UnloadProject")
$dte.ExecuteCommand("Project.ReloadProject")

However, when I install my package using this Install.ps1 I get this warning and error in the package manager console (PM):

PM> Install-Package MyPackage

Successfully installed 'MyPackage 1.0.1'.

Successfully added 'MyPackage 1.0.1' to ClassLibrary13.

Project unavailable.

Project unavailable.

Project unavailable.

Directory '' is not empty. Skipping...

Install failed. Rolling back...

 

Install-Package : Project unavailable.

At line:1 char:16

+ Install-Package <<<< MyPackage

   + CategoryInfo         : NotSpecified: (:) [Install-Package], COMException

   + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

 

Please help me get around this problem?

 


Viewing all articles
Browse latest Browse all 7612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>