MSBuild, Extension Pack and TfsVersion

冷暖自知 提交于 2020-01-05 14:11:32

问题


I am trying to implement what I see in this post: TFS and msbuild version number with last changeset. That is, I am trying to get the last Changeset number at build time so I can use it in an AssemblyVersionInfo.cs.

I am using VS 2008 and TFS 2008. I have installed MSBuild Extension pack v3.5.9.0 (x64). It is in C:\Program Files\MSBuild\ExtensionPack. Here is my MSBuild project:

<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>

Here is how I am running the script:

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

Here is my error message:

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.

Any help appreciated.

Thanks, Scott


回答1:


Looks like MSBuild.ExtensionPack.tasks is trying to find libraries not where they are located. You can open this file and add this in the top of the file

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

in place of other ExtensionTasksPath declarations (just comment them and add this). This should fix the paths problem.
I assume that there exists C:\Program Files\MSBuild\ExtensionPack\MSBuild.ExtensionPack.dll



来源:https://stackoverflow.com/questions/6294002/msbuild-extension-pack-and-tfsversion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!