2016-10-29 6 views
1

는 ILMerge, .NET 4, NuGet : 확인되지 않은 어셈블리 참조는 사용할 수 없습니다 : 명령 행는 ILMerge, .NET 4, NuGet : 확인되지 않은 어셈블리 참조는 사용할 수 없습니다 : 명령 행

내가 하나의 DLL로 내 프로젝트를 포장하기 위해 노력하고있어.
내가 사용하고 있습니다 :
- 비주얼 스튜디오 2015
- NuGet
- ILMerge

내 목표를 달성하기 위해, 나는 ILMerge batch file
추가에게 빌드 후 이벤트했습니다 것 :

"d:\#programming\#visual_studio\merge_all.bat" "$(TargetPath)" $(ConfigurationName) 

그런 다음 약간 수정 된 배치 파일을 사용하여 중복 오류를 없애고 "미확인 어셈블리 참조"오류를 제거하려고 일부 후크를 추가합니다.

불행히도 Google Suggestions
아무런 도움이되지 않습니다.

@ECHO OFF 

rem # usage 
rem # "path\to\merge_all.bat" "$(TargetPath)" $(ConfigurationName) 
rem # "d:\#programming\#visual_studio\merge_all.bat" "$(TargetPath)" $(ConfigurationName) 

rem # set .NET version and output folder name 
set net_version=v4 

set net_path="C:\Windows\Microsoft.NET\Framework\v4.0.30319" 
set net_path_v1="%ProgramFiles%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client" 
set net_path_v2="%ProgramFiles%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" 
set net_path_v3="%ProgramFiles%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6" 

set target_platform=%net_version%,%net_path_v3% 
set lib_path="%ProgramFiles%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" 

set output=merged 

set ILMerge=%ProgramFiles%\Microsoft\ILMerge\ILMerge.exe 

rem # parsing arguments 
set target_path=%1 
set target_file=%~nx1 
set target_dir=%~dp1 
set ConfigurationName=%2 

rem # set output path and result file path 
set outdir=%target_dir%%output% 
set result=%outdir%\%target_file% 
set log_file="%outdir%\merge.log" 

set primary_assembly=%target_path% 

rem # a little looping voodoo from microsoft to get rid of "duplicate" error 
setlocal EnableDelayedExpansion 
set "other_assemblies=" 

for %%f in (%target_dir%*.dll) do (

    if NOT %%~nxf==%target_file% (
     set "other_assemblies=!other_assemblies! %target_dir%%%~nxf" 
    ) 
) 
setlocal DisableDelayedExpansion 

rem # print info 
@echo  Start %ConfigurationName% Merging %target_file%. 
@echo Target: %target_path% 
@echo target_dir: %target_dir% 
@echo Config: %ConfigurationName% 
@echo Log: %log_file% 
@echo primary assembly: %primary_assembly% 
@echo other assemblies: %other_assemblies% 

rem # recreate outdir 
IF EXIST "%outdir%" rmdir /S /Q "%outdir%" 
md "%outdir%" 

set options= /wildcards /targetplatform:%target_platform% /log:%log_file% /out:"%result%" %primary_assembly% %other_assemblies% 

rem # run merge cmd 
@echo Merging: '"%ILMerge%" %options%' 
"%ILMerge%" %options% 

rem # if succeded 
IF %ErrorLevel% EQU 0 (

    rem # clear real output folder and put there result assembly 
    IF %ConfigurationName%==Release (

     del %target_dir%*.* 
     del %target_dir%*.dll 
     del %target_dir%*.pdb 
     del %target_dir%*.xml 
     del %target_dir%*.* 

     copy %result% %target_dir% 
     rmdir /S /Q %outdir% 
     set result=%target_path% 
     @echo Result: %target_file% "-> %target_path%" 
    ) ELSE (
     @echo Result: %target_file% "-> %result%") 

    set status=succeded 
    set errlvl=0  
) ELSE (
    set status=failed 
    set errlvl=1 
    ) 

@echo Merge %status% 
exit %errlvl% 

다음은 빌드 프로세스의 출력입니다 :

가 여기 내 ILMerge 배치 파일의

Unresolved assembly reference not allowed: CommandLine.

:

1>------ Rebuild All started: Project: YouTrackSharpApiWrapper, Configuration: Debug Any CPU ------ 
1>D:\#programming\#visual_studio\YouTrackSharpApiWrapper\ApiWrapper.cs(59,21,59,22): warning CS0168: The variable 'e' is declared but never used 
1> YouTrackSharpApiWrapper -> D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll 
1>  Start Debug Merging YouTrackSharpApiWrapper.dll. 
1> Target: "D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll" 
1> target_dir: D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\ 
1> Config: Debug 
1> Log: "D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\merge.log" 
1> primary assembly: "D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll" 
1> other assemblies: D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll 
1> Merging: '"C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe" /wildcards /targetplatform:v4,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6" /log:"D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\merge.log" /out:"D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\YouTrackSharpApiWrapper.dll" "D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll" D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll' 
1> Merge failed 
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4714,5): error MSB3073: The command ""d:\#programming\#visual_studio\merge_all.bat" "D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll" Debug" exited with code 1. 
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========== 

가 그리고 여기 로그의

그래서, 난 여전히 오류가 발생했습니다 ILMerge :

ILMerge version 2.12.803.0 
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved. 
ILMerge /wildcards /targetplatform:v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6 /log:D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\merge.log /out:D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\YouTrackSharpApiWrapper.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll 
Set platform to 'v4', using directory 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6' for mscorlib.dll 
Running on Microsoft (R) .NET Framework v2.0.50727 
mscorlib.dll version = 2.0.0.0 
The list of input assemblies is: 
    D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll 
    D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll 
    D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll 
    D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll 
The number of files matching the pattern D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll is 1. 
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll 
Trying to read assembly from the file 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharpApiWrapper.dll'. 
    Successfully read in assembly. 
    There were no errors reported in YouTrackSharpApiWrapper's metadata. 
The number of files matching the pattern D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll is 1. 
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll 
Trying to read assembly from the file 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\EasyHttp.dll'. 
    Successfully read in assembly. 
    There were no errors reported in EasyHttp's metadata. 
The number of files matching the pattern D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll is 1. 
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll 
Trying to read assembly from the file 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll'. 
Can not find PDB file. Debug info will not be available for assembly 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\JsonFx.dll'. 
    Successfully read in assembly. 
    There were no errors reported in JsonFx's metadata. 
The number of files matching the pattern D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll is 1. 
D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll 
Trying to read assembly from the file 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\YouTrackSharp.dll'. 
    Successfully read in assembly. 
    There were no errors reported in YouTrackSharp's metadata. 
Checking to see that all of the input assemblies have a compatible PeKind. 
    YouTrackSharpApiWrapper.PeKind = ILonly 
    EasyHttp.PeKind = ILonly 
    JsonFx.PeKind = ILonly 
    YouTrackSharp.PeKind = ILonly 
All input assemblies have a compatible PeKind value. 
AssemblyResolver: Assembly 'EasyHttp' is referencing assembly 'System.Core'. 
    AssemblyResolver: Attempting referencing assembly's directory. 
    AssemblyResolver: Did not find assembly in referencing assembly's directory. 
    AssemblyResolver: Attempting input directory. 
    AssemblyResolver: Did not find assembly in input directory. 
    AssemblyResolver: Attempting user-supplied directories. 
    AssemblyResolver: No user-supplied directories. 
    AssemblyResolver: Attempting framework directory. 
Can not find PDB file. Debug info will not be available for assembly 'System.Core'. 
Resolved assembly reference 'System.Core' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Core.dll'. (Used framework directory.) 
AssemblyResolver: Assembly 'YouTrackSharp' is referencing assembly 'System.Management.Automation'. 
    AssemblyResolver: Attempting referencing assembly's directory. 
    AssemblyResolver: Did not find assembly in referencing assembly's directory. 
    AssemblyResolver: Attempting input directory. 
    AssemblyResolver: Did not find assembly in input directory. 
    AssemblyResolver: Attempting user-supplied directories. 
    AssemblyResolver: No user-supplied directories. 
    AssemblyResolver: Attempting framework directory. 
    AssemblyResolver: Did not find assembly in framework directory. 
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.) 
AssemblyResolver: Assembly 'YouTrackSharp' is referencing assembly 'CommandLine'. 
    AssemblyResolver: Attempting referencing assembly's directory. 
    AssemblyResolver: Did not find assembly in referencing assembly's directory. 
    AssemblyResolver: Attempting input directory. 
    AssemblyResolver: Did not find assembly in input directory. 
    AssemblyResolver: Attempting user-supplied directories. 
    AssemblyResolver: No user-supplied directories. 
    AssemblyResolver: Attempting framework directory. 
    AssemblyResolver: Did not find assembly in framework directory. 
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.) 
Using assembly 'YouTrackSharpApiWrapper' for assembly-level attributes for the target assembly. 
Merging assembly 'YouTrackSharpApiWrapper' into target assembly. 
Merging assembly 'EasyHttp' into target assembly. 
Merging assembly 'JsonFx' into target assembly. 
Assembly level attribute 'System.Security.AllowPartiallyTrustedCallersAttribute' from assembly 'JsonFx' being deleted from target assembly 
Merging assembly 'YouTrackSharp' into target assembly. 
Copying 1 Win32 Resources from assembly 'YouTrackSharpApiWrapper' into target assembly. 
    There were no errors reported in the target assembly's metadata. 
ILMerge: Writing target assembly 'D:\#programming\#visual_studio\YouTrackSharpApiWrapper\bin\Debug\merged\YouTrackSharpApiWrapper.dll'. 
AssemblyResolver: Assembly 'YouTrackSharp' is referencing assembly 'Microsoft.CSharp'. 
    AssemblyResolver: Attempting referencing assembly's directory. 
    AssemblyResolver: Did not find assembly in referencing assembly's directory. 
    AssemblyResolver: Attempting input directory. 
    AssemblyResolver: Did not find assembly in input directory. 
    AssemblyResolver: Attempting user-supplied directories. 
    AssemblyResolver: No user-supplied directories. 
    AssemblyResolver: Attempting framework directory. 
Can not find PDB file. Debug info will not be available for assembly 'Microsoft.CSharp'. 
Resolved assembly reference 'Microsoft.CSharp' to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\Microsoft.CSharp.dll'. (Used framework directory.) 
An exception occurred during merging: 
Unresolved assembly reference not allowed: CommandLine. 
    at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly) 
    at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type) 
    at System.Compiler.Ir2md.VisitReferencedType(TypeNode type) 
    at System.Compiler.Ir2md.GetMemberRefIndex(Member m) 
    at System.Compiler.Ir2md.GetMethodToken(Method m) 
    at System.Compiler.Ir2md.VisitConstruct(Construct cons) 
    at System.Compiler.Ir2md.VisitExpressionList(ExpressionList expressions) 
    at System.Compiler.Ir2md.VisitConstruct(Construct cons) 
    at System.Compiler.Ir2md.VisitAssignmentStatement(AssignmentStatement assignment) 
    at System.Compiler.Ir2md.VisitBlock(Block block) 
    at System.Compiler.Ir2md.VisitBlock(Block block) 
    at System.Compiler.Ir2md.VisitMethodBody(Method method) 
    at System.Compiler.Ir2md.VisitMethod(Method method) 
    at System.Compiler.Ir2md.VisitClass(Class Class) 
    at System.Compiler.Ir2md.VisitModule(Module module) 
    at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation) 
    at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer) 
    at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName) 
    at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module) 
    at ILMerging.ILMerge.Merge() 
    at ILMerging.ILMerge.Main(String[] args) 

죄송합니다. 게시물이 길어서 죄송 합니다만, 2 개 이상의 링크를 삽입 할만큼 마나가 충분하지 않으므로 스레드에서 로그를 붙여 넣어야했습니다. Markdown 지원은 정말 싫습니다. (나는 당신의 로그에서 볼 수있는 바와 같이) ILMerge 매개 변수 문자열이 참조를 포함하지 않는하면서 일부 컴포넌트처럼 보인다

+0

나는 실제로 내 문제를 해결할 것을 주장하지 않습니다. 어쩌면 누군가가 문제의 원인을 알아 내기 위해 디버깅하는 방법을 최소한 알고있을 것입니다. – registered

답변

0

AssemblyResolver: Assembly 'YouTrackSharp' is referencing assembly 'CommandLine'.

명령 줄 구성 요소에 대한 참조가 있습니다.

이 문제를 해결하기 위해 시도해보십시오. ILMerge 호출에 /useFullPublicKeyForReferences 매개 변수를 지정하십시오. 도움이되지 않으면 CommandLib 끝 부분에 라이브러리 위치를 지정하십시오.