nuget - 如何在powershell脚本中的子文件夹中获取项目项

时间:2015-03-04 16:32:18

标签: powershell nuget

我正在尝试编写一个nuGet安装程序powershell脚本,以便在编译项目时将可执行文件复制到输出文件夹(C#assembly)。

查看示例我已经设法实现这一点,但显然$ file是NULL。

我应该怎么做才能访问该文件?

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

# $project = Get-Project

$file = $project.ProjectItems.Item("Shell\Launcher.exe")

# set Build Action to None
$file.Properties.Item("BuildAction").Value = 0

# set Copy to Output Directy to Copy if newer
$file.Properties.Item("CopyToOutputDirectory").Value = 2

1 个答案:

答案 0 :(得分:1)

我找到的答案如下:

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

# $project = Get-Project

$shellFolder = $project.ProjectItems.Item("Shell")
$file = $shellFolder.ProjectItems.Item("Launcher.exe")

# set Build Action to None
$file.Properties.Item("BuildAction").Value = 0

# set Copy to Output Directy to Copy if newer
$file.Properties.Item("CopyToOutputDirectory").Value = 2