How to Format xml based files (csproject) in vsix?

20 views Asked by At

i have a Project Template with Wizard (vsix) and i want to format csproject file when Project Creation is finished. so i am using this codes:

public void RunFinished()
{
  var dte = (DTE)Package.GetGlobalService(typeof(DTE));
  if (File.Exists(project.FullName)) 
  {
    var document = dte.ItemOperations.OpenFile(project.FullName);
    document.Activate();
    document.DTE.ExecuteCommand("Edit.FormatDocument");

    document.Close(vsSaveChanges.vsSaveChangesYes);

  }
}

but i get exception:

System.Runtime.InteropServices.COMException: 'Command "Edit.FormatDocument" is not available.'

above code is working fine for *.cs files. but not working for csproject and xaml files.

i need a code which works fine for xml based files like xaml, csproject.

0

There are 0 answers