ILMerge无法运行新的exe

时间:2016-03-23 14:32:34

标签: c# wpf ilmerge

更新:解决方案:在评论中查看@Matthew解决方案。

通缉结果: WPF Application exe可以作为Standalone运行,复制到usb并运行它而无需安装任何东西。

发生了什么:创建了一个新的exe文件,但是当双击文件时没有任何反应。

编辑: Visual Studio 2015

ILMerge: Nuget包,2.14.1208

我编辑了* .csproj并添加了帖子构建操作

<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
    <CreateItem Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)'=='.dll'">
        <Output ItemName="AssembliesToMerge" TaskParameter="Include" />
    </CreateItem>
    <PropertyGroup>
        <ReferenceAssemblies>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1</ReferenceAssemblies>
        <MergedAssembly>$(ProjectDir)publish\MERGED_ASSEMBLY_NAME.exe</MergedAssembly>
        <ExecString>&quot;$(SolutionDir)\packages\ILMerge.2.14.1208\tools\ILMerge.exe&quot; /out:&quot;$(MergedAssembly)&quot; /internalize /allowDup /targetplatform:v4,&quot;$(ReferenceAssemblies)&quot; &quot;@(IntermediateAssembly)&quot; @(AssembliesToMerge->'&quot;%(FullPath)&quot;', ' ')</ExecString>
    </PropertyGroup>
    <Message Importance="high" Text="Executing ILMerge...with target platform from $(ReferenceAssemblies)" />
    <Message Importance="high" Text="$(ExecString)" />
    <Exec Command="$(ExecString)" />
</Target>

这将运行ilmerge.exe,如果我复制它并在命令提示符下运行它会执行而没有错误。

"D:\Visual Studio\DrawTool\\packages\ILMerge.2.14.1208\tools\ILMerge.exe" /out:"D:\Visual Studio\DrawTool\MyDrawTool\publish\MERGED_ASSEMBLY_NAME.exe" /internalize /allowDup /targetplatform:v4,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1" "obj\Release\MyDrawTool.exe" "D:\Visual Studio\DrawTool\packages\HtmlAgilityPack.1.4.9\lib\Net45\HtmlAgilityPack.dll" "D:\Visual Studio\DrawTool\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll" "D:\Visual Studio\DrawTool\Utils\bin\Release\Utils.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.DataGrid.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.Toolkit.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\de\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\es\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\fr\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\hu\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\it\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\pt-BR\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\ro\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\ru\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\sv\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\zh-Hans\Xceed.Wpf.AvalonDock.resources.dll"

现在,在发布文件夹中创建了文件 MERGED_ASSEMBLY_NAME.exe MERGED_ASSEMBLY_NAME.pdb 。但是,当我试图运行时,没有任何事情发生。

查看事件查看器,发现我认为在尝试启动新的exe文件时出现的这些错误。

Application: MERGED_ASSEMBLY_NAME.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
   at System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
   at System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
   at System.Reflection.Assembly.Load(System.Reflection.AssemblyName)
   at System.Windows.Navigation.BaseUriHelper.GetLoadedAssembly(System.String, System.String, System.String)
   at MS.Internal.AppModel.ResourceContainer.GetResourceManagerWrapper(System.Uri, System.String ByRef, Boolean ByRef)
   at MS.Internal.AppModel.ResourceContainer.GetPartCore(System.Uri)
   at System.IO.Packaging.Package.GetPartHelper(System.Uri)
   at System.IO.Packaging.Package.GetPart(System.Uri)
   at System.Windows.Application.GetResourceOrContentPart(System.Uri)
   at System.Windows.Application.LoadComponent(System.Object, System.Uri)
   at DrawTools.App.InitializeComponent()
   at DrawTools.App.Main()



Faulting application name: MERGED_ASSEMBLY_NAME.exe, version: 1.0.0.0, time stamp: 0x56f2a475
Faulting module name: KERNELBASE.dll, version: 10.0.10240.16683, time stamp: 0x56ad9410
Exception code: 0xe0434352
Fault offset: 0x000b3fc8
Faulting process id: 0x2e60
Faulting application start time: 0x01d1850e83b32550
Faulting application path: D:\Visual Studio\SortDrawTool\MyDrawTools\publish\MERGED_ASSEMBLY_NAME.exe
Faulting module path: C:\Windows\SYSTEM32\KERNELBASE.dll
Report Id: 29963024-3600-4dd4-8700-33b9f6d9fb37
Faulting package full name: 
Faulting package-relative application ID: 


Fault bucket 129052204427, type 5
Event Name: CLR20r3
Response: Not available
Cab Id: 0

Problem signature:
P1: MERGED_ASSEMBLY_NAME.exe
P2: 1.0.0.0
P3: 56f2a475
P4: mscorlib
P5: 4.6.1055.0
P6: 563c0eac
P7: 40fd
P8: 0
P9: System.IO.FileNotFoundException
P10: 

Attached files:
C:\Users\frbafs01\AppData\Local\Temp\WER6D6E.tmp.WERInternalMetadata.xml
C:\Users\frbafs01\AppData\Local\Temp\WER7697.tmp.appcompat.txt
C:\ProgramData\Microsoft\Windows\WER\Temp\WER76D6.tmp.dmp
C:\Users\frbafs01\AppData\Local\Temp\WER7948.tmp.WERDataCollectionFailure.txt
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_MERGED_ASSEMBLY__46cc5e5a6a376272b10de20c482b0dc4fa7ffcf_ee2c95da_cab_3fc07964\memory.hdmp
WERGenerationLog.txt

These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_MERGED_ASSEMBLY__46cc5e5a6a376272b10de20c482b0dc4fa7ffcf_ee2c95da_cab_3fc07964

Analysis symbol: 
Rechecking for solution: 0
Report Id: 29963024-3600-4dd4-8700-33b9f6d9fb37
Report Status: 16396
Hashed bucket: 6c9b4e91e20e53298c770adb3262c861

注意:如果我删除/ allowDup,我会收到此错误

An exception occurred during merging:
ILMerge.Merge: ERROR!!: Duplicate type 'XamlGeneratedNamespace.GeneratedInternalTypeHelper' found in assembly 'Xceed.Wpf.DataGrid'. Do you want to use the /allowDup option?
   at ILMerging.ILMerge.MergeInAssembly(AssemblyNode a, Boolean makeNonPublic, Boolean targetAssemblyIsComVisible)
   at ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)

0 个答案:

没有答案