2016-10-29 32 views
1

ILMerge、.NET 4、NuGet:許可されていない未解決のアセンブリ参照:CommandLineをILMerge、.NET 4、NuGet:未解決のアセンブリ参照は許されない:CommandLineを

を、私は単一のDLLに私のプロジェクトをパックしようとしています。
私が使用している:
を - Visual Studioの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つの以上のリンクを挿入しないように十分なマナを持っているが、その右のスレッドでログインペーストしなければならなかった、と値下げのサポートはここで本当に吸います。

+0

私は実際に私の問題を直ちに解決することを主張していません。おそらく、誰かが少なくとも問題の原因を突き止めるためにそれをデバッグする方法を知っていますか? – registered

答えて

0

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

これは、いくつかのあなたの部品のように思えるILMergeパラメータ文字列は、その参照が含まれていない間(私はあなたのログから見ることができるように)、CommandLineをコンポーネントへの参照を持っています。この問題を解決するための試みにおいて

はILMergeコールの/useFullPublicKeyForReferencesパラメータを指定してみてください。助けにならない場合は、CommandLine最後にライブラリの場所を指定してください。