Search code examples
c#visual-studio-2019vsixbuildaction

Change BuildAction to None in VSIX


So I am currently working on an extension and I want to change the Build Action of a specific ProjectItem to None.

What I tried

I noticed that the ProjectItem had a Properties property which contains the following KeyValuePair wher the key is BuildAction. Therefor I tried to set its Value to prjBuildActionNone which should be the correct value for it.

Anyway, when I hit Play and the code runs and I set a breakpoint on this very line:

prop.Value = "prjBuildActionNone"

The Debugger will never return to the line below and that is it.

Is there anything I am doing wrong with this approach or is this the totally wrong direction and the Properties property is for read-only purposes?


Solution

  • The value should be a member of the prjBuildAction enumeration, e.g. prjBuildAction.prjBuildActionNone.

    Execution is not reaching the next line because the incorrect type is causing an exception.