使用 MSBuild 添加AllowPartiallyTrustedCallers

发布于 2024-08-14 06:11:21 字数 259 浏览 3 评论 0原文

我使用 CC.Net 和 MSBuild 任务来构建一个由许多解决方案和项目组成的应用程序。我们正在使用 AssemblyInfo MSBuild 社区任务来更新 AssemblyInfo.cs 中的版本信息。不幸的是,AllowPartiallyTrustedCallers 属性无法进入,AssemblyInfo 任务告诉我该任务不支持AllowPartiallyTrustedCallers 属性。有没有什么方法可以通过 MSBuild 添加该属性,而不必诉诸于事后仅在文件末尾添加行的自定义任务?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

┈┾☆殇 2024-08-21 06:11:21

当我构建 uNHAddIns 项目的AllowPartiallyTrustedCallers 版本时,我使用 任务完成了此操作。修改后的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)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文