c# - Visual Studio Extension - set "Copy To Output Directory" property -


i'm creating vs extension, , want add file solution , set properties. 1 of them copy output directory, cannot find way of setting it. setting build action works fine, desired property not listed in array while debugging.

private envdte.projectitem addfiletosolution(string filepath) {   var folder = currentproject.projectitems.addfolder(path.getdirectoryname(filepath));   var item = folder.projectitems.addfromfilecopy(filepath);    item.properties.item("buildaction").value = "none";   // item.properties.item("copytooutputdirectory").value = "copyalways"; // doesn't work - dictionary doesn't contain item, throws exception    return item; } 

how can set property newly added item?

for c# or vb projects, cole wu - msft's answer should work.

if you're trying same thing different kind of project might out of luck since each project type has different properties.

from have tried:

  • c# , vb have 23 properties including "copytooutputdirectory"
  • f# has 9 properties including "copytooutputdirectory"
  • node.js has 13 properties , "copytooutputdirectory" missing

look @ property window of file in project trying modify. contain "copytooutputdirectory" property? if not property not available.

edit:

another options set projectitem property through it's attributes (modifying in *.csproj). workaround, not real solution since need reload project afterwards.

private envdte.projectitem addfiletosolution(string filepath) {     var folder = currentproject.projectitems.addfolder(path.getdirectoryname(filepath));     var item = folder.projectitems.addfromfilecopy(filepath);      item.properties.item("buildaction").value = "none";      // setting attribute instead of property, becase property not available     setprojectitempropertyasattribute(currentproject, item, "copytooutputdirectory", "always");      // reload project      return item; }  private void setprojectitempropertyasattribute(project project, projectitem projectitem, string attributename,     string attributevalue) {     ivshierarchy hierarchy;     ((ivssolution)package.getglobalservice(typeof(svssolution)))         .getprojectofuniquename(project.uniquename, out hierarchy);      ivsbuildpropertystorage buildpropertystorage = hierarchy ivsbuildpropertystorage;      if (buildpropertystorage != null)     {         string fullpath = (string)projectitem.properties.item("fullpath").value;          uint itemid;         hierarchy.parsecanonicalname(fullpath, out itemid);          buildpropertystorage.setitemattribute(itemid, attributename, attributevalue);     } } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -