I'm simulating custom debugger with Edit and Continue through VSExtension, so during live debug session, I'm programmatically triggering MSBuild ,compile to generate .obj file which I can use.
enter code here
logger.Verbosity = LoggerVerbosity.Detailed;
MsBuild.Execution.BuildRequestData buildRequest = new MsBuild.Execution.BuildRequestData(projectPath, properties, null, new string[] { "ClCompile" /*target*/ }, null);
MsBuild.Execution.BuildParameters buildParams = new MsBuild.Execution.BuildParameters()
{
DetailedSummary = true, /*false,*/
Loggers = new List<ILogger>() { logger }
};
ThreadPool.QueueUserWorkItem((Object) =>
{
try
{
MsBuild.Execution.BuildResult result = MsBuild.Execution.BuildManager.DefaultBuildManager.Build(buildParams, buildRequest);
if (result.OverallResult == MsBuild.Execution.BuildResultCode.Success)
{
logger.Write(String.Format("compile succeeded \"{0}\"\n", selectedFiles)); //Test.cpp
}
}
}
This works for Project default debug property /Zi, but when I change it to /ZI EDIT and Continue I get build failure error project.IDB file already in use, with suggestion to use /FS.
Test.cpp(0): error C1041: cannot open program database 'C:\Project\Debug\vc142.idb'; if multiple CL.EXE write to the same .PDB file, please use /FS
even if I set /FS in project properties page it is not resolving programmatic build issue.

If I can change debug output path to some other path/set of files in Programmatically invoked MSBuild it will likely resolve, but unable to identify how to set it through MS BuildRequestData and BuildParameters.
I'm passing follwoing properties dictionary to MSBuild Parmeteres
properties.Add("SelectedFiles", DocName);
properties.Add("BuildProjectReferences", "false");
properties.Add("SolutionDir", val("$(SolutionDir)"));
properties.Add("SolutionExt", val("$(SolutionExt)"));
properties.Add("SolutionName", val("$(SolutionName)"));
properties.Add("SolutionFileName", val("$(SolutionFileName)"));
properties.Add("SolutionPath", val("$(SolutionPath)"));
Added Note 1: Going through MSDN found there is VCconfig class using which I can change outputpath and intermediateDirectory, but not sure how to make this work, as MSBuild is one class and VCConfiguration is unrelated different class.
Added Note 2: Here Idea is during live debug while, I'm halted at breakpoint, using dte, MSBuild etc. programmatically I will compile custom file generate FileName.obj and manually patch exe. But
if use /ZI MSBuild fails with vc142.idb in use error.
VS detects EXE is not in synch with Custom File so give Stop Debugging error box.
So may be changing paths for programmatic MSBuild will solve Error 1.
And for Error2 somehow VS detection has to be suprressed to continue debugging.
