title: Visual Studio Extension Reload Project
body: <p>I created a simple visual studio 2015 extension that adds a class to the current project.</p>
  
  <pre class="lang-cs prettyprint-override"><code>Project p = (Project) ProjectsComboBox.SelectedItem;
  
  string projectLocation = Path.GetDirectoryName(p.FileName);
  // I load the project where I want to Add file
  var projectCurrent = new Microsoft.Build.Evaluation.Project(p.FileName);
  
  
  string relativeNewPath = "\\Model\\DAL\\" + ViewNameTexBox.Text + "DAO.cs";
  string newPath = projectLocation + relativeNewPath;
  
  projectCurrent.AddItem("Compile", relativeNewPath);
  projectCurrent.Save();
  
  // Once class added to my project I edit text inside newly create class
  string text = File.ReadAllText("Templates/DAO.cs.txt");
  text = text.Replace("$viewName$", ViewNameTexBox.Text);
  File.WriteAllText(newPath, text);
  </code></pre>
  
  <p>The file is included to the project and modified but visual studio prompt a message asking to reload project. When I do so, the project won't reload.</p>
  
  <blockquote>
    <p>the project has been modified outside the environment</p>
  </blockquote>
  
  <p>I would like to dispose currentProject but project is not IDisposable. Setting currentProject to null has no effect.</p>
  
  <p>How can I tell my code to free currentProject and let Visual Studio reload it ?</p>