我正在尝试将我的商店从使用 VSS 转换为 TFS。
我们当前的代码库由大量 Visual Studio 2008 解决方案组成,我注意到其中一些解决方案似乎会导致 MSBuild 失败,但我无法弄清楚原因。实际的解决方案本身及其持有的项目构建正确,但整体构建仍然失败。
ErrorsAndWarnings.txt 和 Release.txt 文件没有显示任何错误,只有警告(我们需要清理代码中的各种小东西)
BuildLog.txt 文件当然非常庞大,并且包含大量难以理解的文本。据我所知,当遇到其中一个给它带来问题的 SLN 文件时,MSBuild 就会崩溃并死掉。
Task "MSBuild" Global Properties: Configuration=Release Platform=Any CPU OutDir=C:\TFS\REPOSITORY\Full\Binaries\Release\ PublishDir=C:\TFS\REPOSITORY\Full\Binaries\Release\ SkipInvalidConfigurations=true RunCodeAnalysis=false 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): error MSB4018: The "MSBuild" task failed unexpectedly. error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object. error MSB4018: at Microsoft.Build.BuildEngine.SolutionWrapperProject.AssignDependencyLevel(ProjectInSolution project, SolutionParser solution, Dictionary`2 projectsByDependencyLevel) error MSB4018: at Microsoft.Build.BuildEngine.SolutionWrapperProject.AssignDependencyLevel(ProjectInSolution project, SolutionParser solution, Dictionary`2 projectsByDependencyLevel) error MSB4018: at Microsoft.Build.BuildEngine.SolutionWrapperProject.AssignDependencyLevels(SolutionParser solution, Dictionary`2 projectsByDependencyLevel) error MSB4018: at Microsoft.Build.BuildEngine.SolutionWrapperProject.CreateSolutionProject(SolutionParser solution, Project msbuildProject, BuildEventContext projectBuildEventContext, String wrapperProjectToolsVersion, Engine parentEngine, String solutionProjectCache) error MSB4018: at Microsoft.Build.BuildEngine.SolutionWrapperProject.Generate(SolutionParser solution, Project msbuildProject, String toolsVersionOverride, BuildEventContext projectBuildEventContext) error MSB4018: at Microsoft.Build.BuildEngine.Project.Load(String projectFileName, BuildEventContext buildEventContext, ProjectLoadSettings projectLoadSettings) error MSB4018: at Microsoft.Build.BuildEngine.Engine.GetMatchingProject(Project existingProject, String projectFullPath, BuildPropertyGroup globalPropertiesToUse, String toolsVersion, String[] targetNames, BuildEventContext buildEventContext, Boolean toolsVersionPeekedFromProjectFile) error MSB4018: at Microsoft.Build.BuildEngine.Engine.BuildProjectFileInternal(BuildRequest buildRequest) error MSB4018: at Microsoft.Build.BuildEngine.Engine.EngineBuildLoop(BuildRequest terminatingBuildRequest) error MSB4018: at Microsoft.Build.BuildEngine.TaskExecutionModule.BuildProjectFile(Int32 handleId, String[] projectFileNames, String[] targetNames, IDictionary[] globalPropertiesPerProject, IDictionary[] targetOutputsPerProject, EngineLoggingServices loggingServices, String[] toolsVersions, Boolean useResultsCache, Boolean unloadProjectsOnCompletion, BuildEventContext taskContext) error MSB4018: at Microsoft.Build.BuildEngine.EngineProxy.BuildProjectFilesInParallel(String[] projectFileNames, String[] targetNames, IDictionary[] globalProperties, IDictionary[] targetOutputsPerProject, String[] toolsVersions, Boolean useResultsCache, Boolean unloadProjectsOnCompletion) error MSB4018: at Microsoft.Build.Tasks.MSBuild.ExecuteTargets(ITaskItem[] projects, Hashtable propertiesTable, ArrayList targetLists, Boolean stopOnFirstFailure, Boolean rebaseOutputs, IBuildEngine2 buildEngine, TaskLoggingHelper log, ArrayList targetOutputs, Boolean useResultsCache, Boolean unloadProjectsOnCompletion, String toolsVersion) error MSB4018: at Microsoft.Build.Tasks.MSBuild.BuildProjectsInParallel(Hashtable propertiesTable, ArrayList targetLists, Boolean success, Boolean[] skipProjects) error MSB4018: at Microsoft.Build.Tasks.MSBuild.Execute() error MSB4018: at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) Done building target "CoreCompileSolution" in project "TFSBuild.proj" -- FAILED. Done Building Project "C:\TFS\REPOSITORY\Full\BuildType\TFSBuild.proj" (CompileSolution target(s)) -- FAILED. Done executing task "MSBuild" -- FAILED. Done building target "CoreCompileConfiguration" in project "TFSBuild.proj" -- FAILED. Done Building Project "C:\TFS\REPOSITORY\Full\BuildType\TFSBuild.proj" (CompileConfiguration target(s)) -- FAILED. Done executing task "MSBuild" -- FAILED. Done building target "CoreCompile" in project "TFSBuild.proj" -- FAILED. Done Building Project "C:\TFS\REPOSITORY\Full\BuildType\TFSBuild.proj" (CoreCompile target(s)) -- FAILED. Done executing task "MSBuild" -- FAILED. Done building target "CallCompile" in project "TFSBuild.proj" -- FAILED.
I know pasting incredibly verbose error messages in Stack Overflow is lame but the core thing to take from the above is MSBuild is crashing and I can't figure out why. It gives the usual "Object reference not set..." error, which is pretty much universally useless when it's not your code or program you're troubleshooting.
I see that it's referencing TeamFoundation.Build.targets. I look up that file that file but it doesn't really jump out at me what the problem could be. (the line after the comment is the (1008,5) referenced above)
<!-- 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>
起初我以为这告诉我节点中需要替换的项目之一丢失了,但是其他没有问题的解决方案具有类似/相同的设置。
我注意到 MSBuild 的调用堆栈中的一些项目处理目标,问题似乎源于 TeamFoundation.Build.targets 文件,但我不知道下一步要做什么来解决它。
有人遇到过这种情况吗?
最佳答案
我相信解决方案文件已损坏,VS 的容忍度更高。 (如果我没记错的话,这个崩溃可能是由不匹配的花括号引起的)
如果可行,我会从 VS 中重新创建解决方案文件。 Dan(msbuild 团队)
关于tfs - MSBuild 故障排除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/698174/