我想用C#programmability重新加载我的项目,
添加新文件后:
“ProcedureCallSQLServer.cs”
到我的项目:
“MYCodeGen.csproj”
我是这个东西的新手
实现此方法的步骤如下:
// remove compile line from csproj file.
string[] lines = File.ReadAllLines(@"The Path of MYCodeGen.csproj");
var list = new List<string>(lines);
list.Remove(" <Compile Include=\"The Path of ProcedureCallSQLServer.cs\" />");
lines = list.ToArray();
File.WriteAllLines(@"The Path of MYCodeGen.csproj", lines);
// Includ ....
var p = new Microsoft.Build.Evaluation.Project(@"The Path of MYCodeGen.csproj");
p.AddItem("Compile", @"The Path of ProcedureCallSQLServer.cs");
p.Save();
//Build ...
string solution =@"The Path of MYCodeGen.csproj;
System.Diagnostics.Process build = System.Diagnostics.Process.Start(@"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe", string.Format("{0} /build", solution));
build.WaitForExit();
直到现在,一切都还好,文件已包含并构建,但我想重新加载我的项目以防止出现下一条消息
搜索后,我得到下一个代码:
DTE.ExecuteCommand("Project.UnloadProject");
DTE.ExecuteCommand("Project.ReloadProject");
但我得到了下一个错误: -
未实施方法或操作。
任何帮助??