如何在安装项目中使用 IlMerge?
我使用 IlMerge 将项目的所有 dll 合并到一个 exe 中。 我使用主 csproj 的“导入”中引用的目标文件。
目标中的 ExecCommand 是:
<Exec Command=""$(ProgramFiles)\Microsoft\Ilmerge\Ilmerge.exe" /out:@(MainAssembly) "@(IntermediateAssembly)" @(IlmergeAssemblies->'"%(FullPath)"', ' ')" />
这有效。
但是我有一个安装项目,当它构建时,它会忽略“导入”并且不会合并 dll。 如何在安装项目中使用目标文件?
我尝试在主项目的构建后事件(在项目的属性中)中为 Ilmerge 编写相同的代码,但它给了我错误代码 1。
I have use IlMerge to merge all the dlls of my projects in one exe. I use a targets file which is referenced in the "import" of the main csproj.
The ExecCommand in the targets is:
<Exec Command=""$(ProgramFiles)\Microsoft\Ilmerge\Ilmerge.exe" /out:@(MainAssembly) "@(IntermediateAssembly)" @(IlmergeAssemblies->'"%(FullPath)"', ' ')" />
This works.
But then I have a Setup Project, when it builds, it ignores the "import" and it doesn't merge the dlls. How can I use the targets file with the Setup Project?
I have tried writing this same code for Ilmerge in the Post-build event (in properties of the project) of the main project but it gives me error code 1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您查看 MSBuild 社区任务 中的 ILMerge 任务。 ILMerge 任务的文档包含在下载中。 它将消除您现在所做的指定确切命令行参数的复杂性。
关于您的具体问题,除了错误代码 1 之外,您是否收到任何其他错误消息? 发表评论,我会尽力编辑我的回复。
I'd recommend that you check out the ILMerge Task in the MSBuild Community Tasks. Documentation for the ILMerge Task is included in the download. It will take away the complexity of specifying the exact command line arguments as you are doing now.
On your specific issue, other than the error code 1, are you getting any other error message as a result? Comment, and I'll edit my response as best I can.
我的解决方案是这样的:
我将 Ilmerge 目标文件的导入放入 csproj 中,如下所示:
然后在安装项目中,我不将 exe 包含为主要输出,而是将其作为文件及其本地化资源和内容包含在内。
我认为这是可行的,但遗憾的是,在将应用程序打包到安装可执行文件之前,我无法执行应用程序的构建后事件(ilmerge 进程)。
My solution has been this:
I put the import in csproj for the Ilmerge targets file which is this:
Then in the setup project i don't include my exe as primary output, i include it as a file, and its localized resources and content.
This works I think, but it is a pity that i couldn't execute the postbuild event of my application (the ilmerge process) before packing it into the setup exe.