CRM 使用 ILMerge 将框架库与插件项目合并 [英] CRM using ILMerge to merge framework library with plugin projects

查看:59
本文介绍了CRM 使用 ILMerge 将框架库与插件项目合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个程序集:

  1. 主要插件程序集 - 用于我的项目的插件
  2. 框架程序集 - 我想将此程序集与主插件合并,以便我可以重用在不同项目中经常使用的一些常用方法.

我在主插件程序集上安装了 ILMerge 并引用了构建的框架 dll,同时在解决方案上设置了项目构建顺序.

I installed ILMerge on the main plugin assembly and referenced the built out framework dlls while simultaneously setting project build order on the solution.

现在,在我部署之前这看起来没问题.当我尝试使用我的单元测试项目进行调试时,主要问题出现了.

Now, this looks okay before I deploy. The main problem comes when I try to debug using my unit tests project.

在我的单元测试项目中,我引用了主插件程序集,它允许我使用 fakexrmeasy 来运行我的单元测试.但是,既然程序集已经合并,我希望我应该能够在我的单元测试项目中使用框架方法.在测试类中引用主要插件程序集时,我似乎无法访问这些方法.

In my unit tests project, I have a reference to the main plugin assembly which allows me to use fakexrmeasy to run my unit tests. However, now that the assemblies have been merged I expect that I should be able to use the framework methods within my unit tests project. I cant seem to access those methods when referencing the main plugin assemblies in the test classes.

上述所有项目都存在于同一个解决方案中.

All of the projects mentioned above exist within the same solution.

我对 ILMerge 还很陌生,所以可能做错了什么,这很明显.我只是使用内置的 Visual Studio 编译器进行编译.

Im fairly new to ILMerge so might be doing something wrong thats glaringly obvious. I just compile using the built in visual studio compiler.

任何人都可以建议可能出了什么问题吗?

Can anyone suggest what could be going wrong?

推荐答案

首先,我的建议是使用 ILRepack,因为 ILMerge 不再被积极维护.ILRepack 基于 ILMerge 并且是开源的.将 NuGet 包 ILRepack.Lib.MSBuild.Task 添加到您的项目.

First, my advice is to use ILRepack, since ILMerge is no longer being actively maintained. ILRepack is based on ILMerge and is open source. Add NuGet package ILRepack.Lib.MSBuild.Task to your project.

然后将此文件添加到您的项目中并将其命名为ILRepack.targets:

Then add this file to your project and name it ILRepack.targets:

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="ILRepacker" AfterTargets="Build">
    <ItemGroup>
      <InputAssemblies Include="$(OutputPath)$(TargetName)$(TargetExt)" />
      <InputAssemblies Include="$(OutputPath)YourFramework.dll" />
    </ItemGroup>
    <ILRepack
        Parallel="true"
        Internalize="false"
        InternalizeExclude="@(DoNotInternalizeAssemblies)"
        InputAssemblies="@(InputAssemblies)"
        LibraryPath="$(OutputPath)"
        Wildcards="false"
        TargetKind="SameAsPrimaryAssembly"
        DebugInfo="false"
        KeyFile="YourCompany.snk"
        OutputFile="$(OutputPath)Merged\$(AssemblyName).dll"
        LogFile="$(OutputPath)Merged\ILRepack.log"
    />
  </Target>
</Project>

请注意,根据此配置,您的合并 dll 是在名为Merged"的单独文件夹中创建的.这是您在 Dynamics 365 上注册的库.您的单元测试应该只使用插件项目的常规构建输出.

Note according to this configuration your merged dll is created in a separate folder named "Merged". This is the library you register on Dynamics 365. Your unit tests should simply use the plugin project's regular build output.

这篇关于CRM 使用 ILMerge 将框架库与插件项目合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆