【发布时间】:2012-01-04 12:05:29
【问题描述】:
我使用以下代码编译一个 C++ 应用程序:
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!");
但我收到以下错误,任何想法将不胜感激。
构建开始于 2012/01/04 03:32:16 ب.ظ。 MSBUILD:错误 MSB4014: 由于内部故障,构建被中止。 MSBUILD:错误 MSB4014:System.InvalidCastException:无法转换类型的对象 'System.Xml.XmlComment' 键入 'System.Xml.XmlElement'。 MSBUILD: 错误 MSB4014:在 Microsoft.Build.BuildEngine.Project.ProcessProjectChildren(XmlElement projectElement,字符串 projectDirectoryLocation,布尔值 导入项目)MSBUILD:错误 MSB4014:在 Microsoft.Build.BuildEngine.Project.ProcessImportElement(XmlElement importElement,字符串 projectDirectoryLocation,布尔值 导入项目)MSBUILD:错误 MSB4014:在 Microsoft.Build.BuildEngine.Project.ProcessProjectChildren(XmlElement projectElement,字符串 projectDirectoryLocation,布尔值 导入项目)MSBUILD:错误 MSB4014:在 Microsoft.Build.BuildEngine.Project.ProcessImportElement(XmlElement importElement,字符串 projectDirectoryLocation,布尔值 导入项目)MSBUILD:错误 MSB4014:在 Microsoft.Build.BuildEngine.Project.ProcessProjectChildren(XmlElement projectElement,字符串 projectDirectoryLocation,布尔值 导入项目)MSBUILD:错误 MSB4014:在 Microsoft.Build.BuildEngine.Project.ProcessMainProjectElement() MSBUILD:错误 MSB4014:在 Microsoft.Build.BuildEngine.Project.RefreshProjectIfDirty() MSBUILD: 错误 MSB4014:在 Microsoft.Build.BuildEngine.Project.InternalLoadFromXmlDocument(XmlDocument projectXml, ProjectLoadSettings projectLoadSettings) MSBUILD : 错误 MSB4014:在 Microsoft.Build.BuildEngine.Project.Load(字符串 项目文件名,构建事件上下文构建事件上下文, ProjectLoadSettings projectLoadSettings) MSBUILD:错误 MSB4014:
在 Microsoft.Build.BuildEngine.Engine.GetMatchingProject(项目 现有项目、字符串项目FullPath、BuildPropertyGroup globalPropertiesToUse,字符串工具版本,字符串 [] 目标名称, BuildEventContext buildEventContext,布尔值 toolsVersionPeekedFromProjectFile) MSBUILD:错误 MSB4014:在 Microsoft.Build.BuildEngine.Engine.BuildProjectFileInternal(BuildRequest buildRequest)MSBUILD:错误MSB4014:在 Microsoft.Build.BuildEngine.Engine.EngineBuildLoop(BuildRequest 终止BuildRequest)MSBUILD:错误MSB4014:在 Microsoft.Build.BuildEngine.Engine.PostProjectEvaluationRequests(项目 项目,字符串 [] 项目文件,字符串 [] [] 目标名称, BuildPropertyGroup[] globalPropertiesPerProject, IDictionary[] targetOutputsPerProject, BuildSettings buildFlags, String[] 工具版本)
【问题讨论】:
-
可以直接在Visual Studio中构建C++项目吗?
-
可能是 MSBuild 中的一个 bug:XmlComment 不是从 XmlElement 派生的,因此无法强制转换为 XmlElement。
-
我会查看 .vcxproj 文件内部,看看是否有任何 XML cmets,然后删除它们。
-
没有xml除了以下:
-
您找到解决方案了吗?我目前在将
Microsoft.Build.BuildEngine.Project.Load用于在 VS 本身中加载良好的项目时遇到同样的问题。看来问题出在"C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.props"中的cmets@
标签: .net visual-c++ compilation