2009-12-03 70 views
0

我正在使用CC.Net和MSBuild任務來構建由多個解決方案和項目組成的應用程序。我們正在使用AssemblyInfo MSBuild社區任務來更新AssemblyInfo.cs中的版本信息。不幸的是,AllowPartiallyTrustedCallers屬性沒有進入,並且AssemblyInfo任務告訴我該任務不支持AllowPartiallyTrustedCallers屬性。有什麼辦法可以通過MSBuild添加該屬性,而不必求助於一個自定義任務,只需在文件末尾粘貼該行即可?使用MSBuild添加AllowPartiallyTrustedCallers

回答

0

我在構建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)