MSBuild,Extension Pack和TfsVersion

时间:2011-06-09 14:01:39

标签: visual-studio-2008 msbuild team-build msbuildcommunitytasks

我正在努力实现我在这篇文章中看到的内容:TFS and msbuild version number with last changeset。也就是说,我试图在构建时获取最后一个Changeset编号,以便我可以在AssemblyVersionInfo.cs中使用它。

我正在使用VS 2008和TFS 2008.我已经安装了MSBuild Extension pack v3.5.9.0(x64)。它位于C:\ Program Files \ MSBuild \ ExtensionPack中。这是我的MSBuild项目:

<Project ToolsVersion="3.5" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="C:\Program Files\MSBuild\ExtensionPack\MSBuild.ExtensionPack.tasks"/>
  <Target Name="Default">
    <TfsVersion  TfsLibraryLocation="C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies"
                 LocalPath="$(SolutionRoot)">
      <Output TaskParameter="Changeset" PropertyName="ChangesetNumber"/>
    </TfsVersion>
    <Message Text="TFS ChangeSetNumber: $(ChangesetNumber)" />
  </Target>
</Project>

以下是我运行脚本的方法:

C:\Build\TeamBuildTypes\Nightly_Main>MSbuild test.proj

这是我的错误消息:

C:\Build\TeamBuildTypes\Nightly_Main\test.proj(4,5): error MSB4062: The "MSBuild.ExtensionPack.VisualStudio.TfsVersion" task could not be loaded from the asse
mbly C:\Program Files (x86)\MSBuild\ExtensionPack\MSBuild.ExtensionPack.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\ExtensionPack\MSBuild.ExtensionPack.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available.

任何帮助表示感谢。

谢谢, 斯科特

1 个答案:

答案 0 :(得分:1)

看起来MSBuild.ExtensionPack.tasks正在尝试查找库而不是它们所在的位置。您可以打开此文件并将其添加到文件顶部

<ExtensionTasksPath>C:\Program Files\MSBuild\ExtensionPack\</ExtensionTasksPath>

代替其他ExtensionTasksPath声明(只需注释并添加)。这应该解决路径问题 我假设存在C:\Program Files\MSBuild\ExtensionPack\MSBuild.ExtensionPack.dll