简体   繁体   English

ILMerge和Web资源

[英]ILMerge and Web Resources

We're attemtping to merge our DLL's into one for deployment, thus ILMerge. 我们正在努力将我们的DLL合并为一个用于部署,因此ILMerge。 Almost everything seems to work great. 几乎所有事情似乎都很有效。 We have a couple web controls that use ClientScript.RegisterClientScriptResource and these are 404-ing after the merge (These worked before the merge). 我们有几个使用ClientScript.RegisterClientScriptResource Web控件,这些在合并后是404-ing(这些在合并之前有效)。

For example one of our controls would look like 例如,我们的控件之一就像

namespace Company.WebControls
{
  public class ControlA: CompositeControl, INamingContainer
  {
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        this.Page.ClientScript.RegisterClientScriptResource(typeof(ControlA), "Company.WebControls.ControlA.js");                
    }      
  }
}

It would be located in Project WebControls, assembly Company.WebControls. 它将位于Project WebControls,程序集Company.WebControls中。 Underneath would be ControlA.cs and ControlA.js. 下面是ControlA.cs和ControlA.js。 ControlA.js is marked as an embedded resource. ControlA.js被标记为嵌入式资源。 In the AssemblyInfo.cs I include the following: 在AssemblyInfo.cs中,我包括以下内容:

[assembly: System.Web.UI.WebResource("Company.WebControls.ControlA.js", "application/x-javascript")]

After this is merged into CompanyA.dll, what is the proper way to reference this web resource? 在将其合并到CompanyA.dll之后,引用此Web资源的正确方法是什么? The ILMerge command line is as follows (from the bin directory after the build): "C:\\Program Files\\Microsoft\\ILMerge\\ILMerge.exe" /keyfile:../../CompanySK.snk /wildcards:True /copyattrs:True /out:Company.dll Company.*.dll ILMerge命令行如下(从构建后的bin目录): "C:\\Program Files\\Microsoft\\ILMerge\\ILMerge.exe" /keyfile:../../CompanySK.snk /wildcards:True /copyattrs:True /out:Company.dll Company.*.dll

OK - I got this working. 好的 - 我有这个工作。 It looks like the primary assembly was the only one whose assembly attributes were being copied. 看起来主要程序集是唯一一个正在复制其程序集属性的程序集。 With copyattrs set, the last one in would win, not a merge (as far as I can tell). 随着copyattrs设置,最后一个将赢,而不是合并(据我所知)。 I created a dummy project to reference the other DLL's and included all the web resources from those projects in the dummy assembly info - now multiple resources from multiple projects are all loading correctly. 我创建了一个虚拟项目来引用其他DLL,并在虚拟程序集信息中包含这些项目中的所有Web资源 - 现在来自多个项目的多个资源都正确加载。

Final post-build command line for dummy project: "C:\\Program Files\\Microsoft\\ILMerge\\ILMerge.exe" /keyfile:../../Company.snk /wildcards:True /out:Company.dll Company.Merge.dll Company.*.dll 虚拟项目的最终构建后命令行:“C:\\ Program Files \\ Microsoft \\ ILMerge \\ ILMerge.exe”/keyfile:../../Company.snk / wildcards:True /out:Company.dll Company.Merge .dll Company。*。dll

You need to set /allowMultiple along with /copyattrs. 你需要设置/ allowMultiple和/ copyattrs。 It is only then that ILMerge will merge the embedded resources from all assemblies. 只有这样,ILMerge才会合并所有程序集中的嵌入式资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM