使用 ProjectItems.item

发布于 2024-12-02 03:19:58 字数 465 浏览 1 评论 0原文

使用 NuGet 时,我尝试使用 powershell 脚本将文件更改为嵌入式资源。我使用此处论坛上推荐的小型 powershell 脚本。但是,我的脚本仅当文件不在文件夹中时才有效。

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

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

我如何调整这一行来查找文件,即使它位于文件夹中:

$item = $project.ProjectItems.Item("ReleaseNotes.txt")

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")

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

思念满溢 2024-12-09 03:19:58

嗯,我找到了。

ProjectItems 是一个包含文件和文件夹的综合列表。为了访问文件夹/ReleaseNotes.txt,您必须沿着导航树向下移动。这就是解决方案

param($installPath, $toolsPath, $package, $project)
$item = $project.ProjectItems.Item("Folder").ProjectItems.Item("ReleaseNotes.txt")
$item.Properties.Item("BuildAction").Value = [int]3

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文