저는 현재 프로젝트에 클래스를 추가하는 간단한 Visual Studio 2015 확장을 만들었습니다.Visual Studio Extension Reload Project
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);
파일이 프로젝트에 포함되어 있으며 수정되었지만 visual studio에서 프로젝트를 다시로드하라는 메시지를 표시합니다. 그렇게하면 프로젝트가 다시로드되지 않습니다.
프로젝트
환경
내가 currentProject을 처분하고 싶지만 프로젝트는 IDisposable 아닌 외부에서 수정되었습니다. currentProject를 null로 설정해도 아무 효과가 없습니다.
어떻게하면 currentProject를 비우고 Visual Studio에서 다시로드하도록 할 수 있습니까?
이유 [태그 : C] 태그? –
@IanAbbott 클릭 자동 완성을 놓쳤습니다. C로 변경했습니다. – Yvain
다른 방법으로이 기능을 찾았습니다.이 답변을 참조하십시오. [post] (https://stackoverflow.com/a/44160484/1317323) – Yvain