.net - ILMerge 程序集的运行时版本是 v4.0.20926;预期版本是 v4.0.30319

标签 .net ilmerge

这是我的 .csproj AfterBuild 的样子:

  <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
    <Exec Command="&quot;..\Tools\ILMerge\ILMerge.exe&quot; /internalize /ndebug /out:@(MainAssembly) /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 &quot;@(IntermediateAssembly)&quot; @(ReferenceCopyLocalPaths->'&quot;%(FullPath)&quot;', ' ')" Condition=" '$(TargetFrameworkVersion)' == 'v4.0'" />
  </Target>

我运行的是 64 位 Windows。我尝试将 .NET Framework 从 ...\Microsoft.NET\Framework\... 更改为 ...\Microsoft.NET\Framework64\...但它没有帮助。

我还在 ILMerge 目录中创建了 ILMerge.exe.config:

<?xml version ="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
    </startup>
</configuration>

为什么 ILMerge 不生成 4.0.30319 程序集?

最佳答案

编辑:此问题已在 2011 年 5 月 2 日发布的 v2.11.0502 中修复,因此我删除了自定义版本的下载链接。

我已修复 ILMerge.exe (v2.10.0526),以便它设置目标运行时版本 v4.0.30319 而不是 v4.0.20926。您可以从此链接下载固定版本的 ILMerge.exe:

(链接已删除,下载正式版here)

像往常一样用这个参数运行它

/targetplatform:v4,c:\Windows\Microsoft.NET\Framework\v4.0.30319

输出程序集现在将以 v4.0.30319 为目标。我已经用 Reflector 检查过,没问题。让我知道你的结果。

请注意,您不需要使用那个 ILMerge.exe.config,我猜它是为了使用 .Net 4 框架运行 ILMerge.exe 本身,但这并不意味着它会强制 ILMerge.exe 生成 .净 4 个程序集。输出程序集的目标框架版本仅由 /targetplatform 参数控制。

关于.net - ILMerge 程序集的运行时版本是 v4.0.20926;预期版本是 v4.0.30319,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2820117/

相关文章:

c# - ADFS - Windows 集成 OR Forms 身份验证

c# - 退出时杀死进程

.net - 如何将 httpRuntime maxRequestLength ="8096"集成到 app.config [Webservices]

c# - 将单独的 DLL 合并为一个程序集以用于开源分发

c# - 了解 IlMerge - 如何打包一个可执行文件及其所有相关的 dll

c# - ILMerge 最佳实践

c# - ILMerge问题

ilmerge - 将 .dll 与 .exe 合并

.net - 如何捕获MVC View 的异常?

c# - 延迟模板字符串插值