I am executing a PowerShell script when initializing a NuGet dependency with the Visual Studio NuGet Package Manager and I have an error stating that EnvDTE.ProjectItems.AddFolder(string, string) is not implemented :
Exception calling "AddFolder" with "1" argument(s): "Exception calling "InvokeMethod" with "3" argument(s): "Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL))""
Here is the script in question :
$deployFolder = $solution.Projects | where-object { $_.ProjectName -eq "Packages" } | select -first 1
$folderItems = Get-Interface $deployFolder.ProjectItems ([EnvDTE.ProjectItems])
# add all our support deploy scripts to our Support solution folder
ls $deployTarget | foreach-object {
if (Test-Path $_.FullName -PathType Container) {
$folderItems.AddFolder($_.FullName)
}
} > $null
The same problem happens with EnvDTE.ProjectItems.AddFromDirectory(String)
from the microsoft documentation AddFolder should be implemented: https://docs.microsoft.com/en-ca/dotnet/api/envdte.projectitems?view=visualstudiosdk-2017#Methods
I have installed the Visual Studio 2017 SDK and have no problem calling:
EnvDTE.ProjectItems.AddFromFile(String)
Are the docs wrong or am I missing something?
Found the answer, the problem is created when using the Get-Interface
cmdlet. It removes for some reasons the implementation of the class it is used on.
Removing the Get-Interface
and the ([EnvDTE.ProjectItems])
fixed the problem:
$folderItems = $deployFolder.ProjectItems
User contributions licensed under CC BY-SA 3.0