views:

156

answers:

1

I am using CC.Net with MSBuild tasks to build an application that is composed of a number of solutions and projects. We are using the AssemblyInfo MSBuild Community task to update version info in AssemblyInfo.cs. Unfortunately the AllowPartiallyTrustedCallers attribute doesn't get in and the AssemblyInfo task tells me that the AllowPartiallyTrustedCallers attribute is not supported by the task. Is there any way to add that attribute through MSBuild without having to resort to a custom task that just tacks the line at the end of the file after-the-fact?

A: 

I did it using the <WriteLinesToFile/> task when I was building an AllowPartiallyTrustedCallers version of the uNHAddIns project. The modified GenerateAssemblyInfo target looked like this:

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

Not very pretty but it works (i'm using msbuild 3.5)

rob bentley