I use the following code to compile one C++ application:
Engine engine = new Engine(); engine.BinPath = @"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319"; BuildPropertyGroup group = new BuildPropertyGroup(); group.SetProperty("Configuration", "Debug"); engine.BuildEnabled = true; FileLogger logger = new FileLogger(); logger.Parameters = @"logfile=C:\tmp\build.log"; engine.RegisterLogger(logger); bool success = engine.BuildProjectFile(@"E:\sv_repos\Test\Test\VS2010\Test\Test\Test.vcxproj", new string[] { "Build" }, group); engine.UnregisterAllLoggers(); if (success) MessageBox.Show("build!"); But I get the following error, any idea will be appreciated.
Build started 2012/01/04 03:32:16 ب.ظ. MSBUILD : error MSB4014: The build was aborted because of an internal failure. MSBUILD : error MSB4014: System.InvalidCastException: Unable to cast object of type 'System.Xml.XmlComment' to type 'System.Xml.XmlElement'. MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Project.ProcessProjectChildren(XmlElement projectElement, String projectDirectoryLocation, Boolean importedProject) MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Project.ProcessImportElement(XmlElement importElement, String projectDirectoryLocation, Boolean importedProject) MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Project.ProcessProjectChildren(XmlElement projectElement, String projectDirectoryLocation, Boolean importedProject) MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Project.ProcessImportElement(XmlElement importElement, String projectDirectoryLocation, Boolean importedProject) MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Project.ProcessProjectChildren(XmlElement projectElement, String projectDirectoryLocation, Boolean importedProject) MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Project.ProcessMainProjectElement() MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Project.RefreshProjectIfDirty() MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Project.InternalLoadFromXmlDocument(XmlDocument projectXml, ProjectLoadSettings projectLoadSettings) MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Project.Load(String projectFileName, BuildEventContext buildEventContext, ProjectLoadSettings projectLoadSettings) MSBUILD : error MSB4014:
at Microsoft.Build.BuildEngine.Engine.GetMatchingProject(Project existingProject, String projectFullPath, BuildPropertyGroup globalPropertiesToUse, String toolsVersion, String[] targetNames, BuildEventContext buildEventContext, Boolean toolsVersionPeekedFromProjectFile) MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Engine.BuildProjectFileInternal(BuildRequest buildRequest) MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Engine.EngineBuildLoop(BuildRequest terminatingBuildRequest) MSBUILD : error MSB4014: at Microsoft.Build.BuildEngine.Engine.PostProjectEvaluationRequests(Project project, String[] projectFiles, String[][] targetNames, BuildPropertyGroup[] globalPropertiesPerProject, IDictionary[] targetOutputsPerProject, BuildSettings buildFlags, String[] toolVersions)
Microsoft.Build.BuildEngine.Project.Loadfor a project that loads fine in VS itself. It seems the problem are the comments in"C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.props"