我在構建uNHAddIns項目的AllowPartiallyTrustedCallers版本時使用了<WriteLinesToFile/>
任務。修改後的GenerateAssemblyInfo目標是這樣的:
<Target Name="GenerateAssemblyInfo" DependsOnTargets="HgRevision; SVNRevision">
<MakeDir Directories="$(AssemblyOutputDir)" />
<Message Text="Writing the revision number $(BUILD_VCS_NUMBER) in assemblyinfo.cs." />
<AssemblyInfo
AssemblyCompany ="$(AssemblyCompany)"
AssemblyCopyright="$(AssemblyCopyright)"
AssemblyDescription="$(AssemblyDescription)"
AssemblyProduct="$(AssemblyProduct)"
AssemblyTitle ="$(AssemblyTitle)"
CodeLanguage="$(AssemblyCodeLanguage)"
CLSCompliant ="$(AssemblyClsCompliant)"
AssemblyInformationalVersion="$(AssemblyVersion).$(BUILD_VCS_NUMBER)"
AssemblyVersion ="$(AssemblyVersion).$(BUILD_VCS_NUMBER)"
OutputFile="$(AssemblyOutputFile)"
/>
<WriteLinesToFile File="$(AssemblyOutputFile)" Lines="[assembly: System.Security.AllowPartiallyTrustedCallers]" />
</Target>
不是很漂亮,但它工作(我使用的MSBuild 3.5)