Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ProjectItems.item

When working with NuGet, I'm attempting to use a powershell script to change a file to an embedded resource. I'm using a small powershell script recommended on the forums here. However, my script only works when the file isn't in a folder.

param($installPath, $toolsPath, $package, $project)

$item = $project.ProjectItems.Item("Folder\ReleaseNotes.txt")
$item.Properties.Item("BuildAction").Value = [int]3

How can I adjust this line to find a file even if it is in a folder:

$item = $project.ProjectItems.Item("ReleaseNotes.txt")
like image 950
Aardvark Avatar asked Aug 29 '11 19:08

Aardvark


Video Answer


1 Answers

Well, I found it.

ProjectItems is a comprehensive list that contains both files and folders. In order to access folder/ReleaseNotes.txt you have to go down the nav tree. This is the solution

param($installPath, $toolsPath, $package, $project)
$item = $project.ProjectItems.Item("Folder").ProjectItems.Item("ReleaseNotes.txt")
$item.Properties.Item("BuildAction").Value = [int]3
like image 103
Aardvark Avatar answered Sep 19 '22 12:09

Aardvark