开发者

Using ProjectItems.item

开发者 https://www.devze.com 2023-03-31 19:13 出处:网络
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 onl

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("ReleaseNo开发者_开发问答tes.txt")


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
0

精彩评论

暂无评论...
验证码 换一张
取 消