MSBuild未知函数'file :: get-checksum'

时间:2014-07-01 10:33:24

标签: c# msbuild

我正在尝试使用MSBuild获取文件的MD5并提供错误:

C:\TeamCity\buildAgent\work\3614a553d9bd12e6\IntegradorWS.build(488,6):
Unknown function 'file::get-checksum'.
Expression: ${servicos.senha}${file::get-checksum(publicar.zip, 'MD5')}
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

在References中添加MSBuild.ExtensionPack,在导入中添加.csproj:

<Import Project="C:\Program Files\MSBuild\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks" />

此代码出错:

<property name="publicar.checksum" value="${servicos.senha}${file::get-checksum(publicar.zip, 'MD5')}" />

1 个答案:

答案 0 :(得分:1)

属性行的语法看起来不像MSBuild语法。我这样做了:

 <MSBuild.ExtensionPack.FileSystem.File TaskAction="GetChecksum" Path="test.txt">
   <Output TaskParameter="Checksum" PropertyName="chksm"/>
 </MSBuild.ExtensionPack.FileSystem.File>
 <Message Text="MD5 checksum is: $(chksm)" />

输出显示文件的MD5校验和:

  Getting Checksum for file: test.txt
  MD5 checksum is: 3BAB25A3E651A9E4A00473D2257B99F9