GetAssemblyIdentity 是你需要的工具。这个任务输出包含了名为 Version、PublicKeyToken 和 Culture 的元数据项。
<ItemGroup>
<MyAssemblies Include="File1.dll;File2.dll" />
</ItemGroup>
<Target Name="RetrieveIdentities>
<GetAssemblyIdentity
AssemblyFiles="@(MyAssemblies)">
<Output
TaskParameter="Assemblies"
ItemName="MyAssemblyIdentities"/>
</GetAssemblyIdentity>
</Target>
感谢madgnome!我想分享一下这个可行的代码。
<Target Name="UpdateWebConfigVersion">
<GetAssemblyIdentity AssemblyFiles="lib\foo.dll">
<Output TaskParameter="Assemblies" ItemName="fooAssemblyInfo"/>
</GetAssemblyIdentity>
<XmlUpdate XmlFileName="src\Web\ServiceModel.Extensions.config"
XPath="//extensions/behaviorExtensions/add[@name='silverlightFaults']/@type"
Value="foo.ServiceModel.Extensions.Behaviors.SilverlightFaultBehavior, foo, Version=%(fooAssemblyInfo.Version), Culture=neutral, PublicKeyToken=XXXXXXXX"/>
</Target>