How do you change the BuildAction of a C# project file using an enumeration in Powershell?

509 Views Asked by At

I found this question and this answer on how to set the BuildAction (using Powershell) of a file in a C# Project.

Basically, get the specified item, then set the Value of the "BuildAction":

$item = $project.ProjectItems | where-object {$_.Name -eq "ReleaseNotes.txt"} $item.Properties.Item("BuildAction").Value = [int]3

I'm just wondering if there is a way to utilize the prjBuildAction Enumeration values (it doesn't seem to work for me).

I've attempted to modify the second statement but it doesn't change the BuildAction:

$item.Properties.Item("BuildAction").Value = prjBuildActionContent

So, is there any way to use an enumeration value instead of [int]3?

1

There are 1 best solutions below

1
izik lisbon On
$item.Properties.Item("ItemType").Value = "Content"