对 MSBuild 失败进行故障排除

Tom*_*idd 4 msbuild tfs

我正在尝试将我的商店从使用 VSS 转换为 TFS。

我们当前的代码库由大量 Visual Studio 2008 解决方案组成,我注意到其中一些似乎导致 MSBuild 失败,但我不知道为什么。实际的解决方案本身及其持有的项目构建正确,但整体构建仍然失败。

ErrorsAndWarnings.txt 和 Release.txt 文件没有显示错误,只有警告(代码中的各种小东西我们需要清理)

BuildLog.txt 文件当然非常庞大,其中包含大量难以理解的文本。不过,据我所知,当涉及到这些 SLN 文件中的一个给它带来问题时,MSBuild 只会崩溃并死亡。

任务“MSBuild”
  全局属性:
    配置=发布
    平台=任何 CPU
    OutDir=C:\TFS\REPOSITORY\Full\Binaries\Release\
    PublishDir=C:\TFS\REPOSITORY\Full\Binaries\Release\
    跳过无效配置=真
    运行代码分析=假
    VCBuildOverride=C:\TFS\REPOSITORY\Full\Sources\Code\Solution\Solution.sln.Release.vsprops
    VCBuildAdditionalLibPaths=
    VCBuildAdditionalOptions=
    VCBuildToolPath=
    VCBuildUseEnvironment=
    TeamBuildConstants=_TEAM_BUILD_
    TargetsNotLogged=GetTargetPath;GetNativeManifest;GetCopyToOutputDirectoryItems

C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(1008,5): 
错误 MSB4018:“MSBuild”任务意外失败。
错误 MSB4018:System.NullReferenceException:未将对象引用设置为对象的实例。
错误 MSB4018:在 Microsoft.Build.BuildEngine.SolutionWrapperProject.AssignDependencyLevel(ProjectInSolution 项目,SolutionParser 解决方案,Dictionary`2 projectsByDependencyLevel)
错误 MSB4018:在 Microsoft.Build.BuildEngine.SolutionWrapperProject.AssignDependencyLevel(ProjectInSolution 项目,SolutionParser 解决方案,Dictionary`2 projectsByDependencyLevel)
错误 MSB4018:在 Microsoft.Build.BuildEngine.SolutionWrapperProject.AssignDependencyLevels(SolutionParser solution, Dictionary`2 projectsByDependencyLevel)
错误 MSB4018:在 Microsoft.Build.BuildEngine.SolutionWrapperProject.CreateSolutionProject(SolutionParser 解决方案,项目 msbuildProject,BuildEventContext 项目BuildEventContext,字符串 wrapperProjectToolsVersion,引擎 parentEngine,字符串 solutionProjectCache)
错误 MSB4018:在 Microsoft.Build.BuildEngine.SolutionWrapperProject.Generate(SolutionParser 解决方案,项目 msbuildProject,字符串工具版本覆盖,BuildEventContext 项目BuildEventContext)
错误 MSB4018:在 Microsoft.Build.BuildEngine.Project.Load(String projectFileName, BuildEventContext buildEventContext, ProjectLoadSettings projectLoadSettings)
错误 MSB4018: 在 Microsoft.Build.BuildEngine.Engine.GetMatchingProject(Project existingProject, String projectFullPath, BuildPropertyGroup globalPropertiesToUse, String toolsVersion, String[] targetNames, BuildEventContext buildEventContext, Boolean toolsVersionPeekedFromProjectFile)
错误 MSB4018:在 Microsoft.Build.BuildEngine.Engine.BuildProjectFileInternal(BuildRequest buildRequest)
错误 MSB4018:在 Microsoft.Build.BuildEngine.Engine.EngineBuildLoop(BuildRequest terminatingBuildRequest)
错误 MSB4018:在 Microsoft.Build.BuildEngine.TaskExecutionModule.BuildProjectFile(Int32 handleId, String[] projectFileNames, String[] targetNames, IDictionary[] globalPropertiesPerProject, IDictionary[] targetOutputsPerProject, EngineLoggingServices loggingServices, String[] toolsVersions, Boolean useResultsCachesOnCompletion , BuildEventContext taskContext)
错误 MSB4018:在 Microsoft.Build.BuildEngine.EngineProxy.BuildProjectFilesInParallel(String[] projectFileNames, String[] targetNames, IDictionary[] globalProperties, IDictionary[] targetOutputsPerProject, String[] toolsVersions, Boolean useResultsCache, Boolean unloadProjectsOnCompletion)
错误 MSB4018:在 Microsoft.Build.Tasks.MSBuild.ExecuteTargets(ITaskItem[] 项目、Hashtable propertiesTable、ArrayList targetLists、Boolean stopOnFirstFailure、Boolean rebaseOutputs、IBuildEngine2 buildEngine、TaskLoggingHelper 日志、ArrayList targetOutputs、Boolean useResultsCache、Boolean unloadProjectsOnFirstFailure)
错误 MSB4018:在 Microsoft.Build.Tasks.MSBuild.BuildProjectsInParallel(Hashtable propertiesTable, ArrayList targetLists, Boolean success, Boolean[] skipProjects)
错误 MSB4018:在 Microsoft.Build.Tasks.MSBuild.Execute()
错误 MSB4018:在 Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
在项目“TFSBuild.proj”中完成构建目标“CoreCompileSolution”——失败。
完成构建项目“C:\TFS\REPOSITORY\Full\BuildType\TFSBuild.proj”(CompileSolution 目标)——失败。
完成执行任务“MSBuild”——失败。
在项目“TFSBuild.proj”中完成构建目标“CoreCompileConfiguration”——失败。
完成构建项目“C:\TFS\REPOSITORY\Full\BuildType\TFSBuild.proj”(CompileConfiguration 目标)——失败。
完成执行任务“MSBuild”——失败。
在项目“TFSBuild.proj”中完成构建目标“CoreCompile”——失败。
完成构建项目“C:\TFS\REPOSITORY\Full\BuildType\TFSBuild.proj”(CoreCompile 目标)——失败。
完成执行任务“MSBuild”——失败。
在项目“TFSBuild.proj”中完成构建目标“CallCompile”——失败。

我知道在 Stack Overflow 中粘贴令人难以置信的冗长错误消息是蹩脚的,但从上面得出的核心内容是MSBuild 崩溃了,我不知道为什么。它给出了通常的“未设置对象引用...”错误,当它不是您的代码或程序进行故障排除时,这几乎是无用的。

我看到它引用了 TeamFoundation.Build.targets。我查找那个文件那个文件,但它并没有真正让我跳出问题可能是什么。(注释后的行是上面引用的 (1008,5))

<!-- Build using MSBuild task -->
<MSBuild BuildInParallel="$(BuildSolutionsInParallel)"
         Projects="$(Solution)"
         Properties="Configuration=$(Configuration);Platform=$(Platform);$(OutDirOption);$(PublishDirOption);SkipInvalidConfigurations=$(SkipInvalidConfigurations);$(FxCopDirOption);$(ReferencePathOption);$(CodeAnalysisOption);
                         VCBuildOverride=$(VsPropsFile);VCBuildAdditionalLibPaths=$(VCBuildAdditionalLibPaths);VCBuildAdditionalOptions=$(VCBuildAdditionalOptions);VCBuildToolPath=$(VCBuildToolPath);VCBuildUseEnvironment=$(VCBuildUseEnvironment);
                         TeamBuildConstants=$(TeamBuildConstants);TargetsNotLogged=$(TargetsNotLogged);$(CustomPropertiesForBuild);$(CustomProperties)"
         Targets="$(Targets)"
         StopOnFirstFailure="$(StopOnFirstFailure)">
  <Output TaskParameter="TargetOutputs" ItemName="CompilationOutputs" />
</MSBuild>
Run Code Online (Sandbox Code Playgroud)

起初我以为这告诉我节点中需要替换的项目之一丢失了,但其他没有问题的解决方案具有类似/相同的设置。

我注意到 MSBuild 的调用堆栈中的一些项目处理目标,问题似乎源于 TeamFoundation.Build.targets 文件,但我不知道接下来要做什么来解决它。

有没有人遇到过这个?

小智 5

我相信解决方案文件已损坏,并且VS更宽容。(如果我没记错的话,这次崩溃可能是由不匹配的大括号引起的)

如果可行,我会从 VS 中重新创建解决方案文件。丹(msbuild 团队)