/// <summary> /// Initializes a new instance of the <see cref="TargetPlatform"/> class. /// </summary> /// <param name="platform">The .NET framework target version.</param> /// <param name="path">The directory where <c>mscorlib.dll</c> can be found.</param> public TargetPlatform(TargetPlatformVersion platform, DirectoryPath path) { if (path == null) { throw new ArgumentNullException("path"); } _platform = platform; _path = path; }
private static string GetTargetPlatformString(TargetPlatformVersion version) { switch (version) { case TargetPlatformVersion.v1: return "v1"; case TargetPlatformVersion.v11: return "v1.1"; case TargetPlatformVersion.v2: return "v2"; case TargetPlatformVersion.v4: return "v4"; default: throw new NotSupportedException("The provided ILMerge target platform is not valid."); } }
/// <summary> /// Implement IEquatable /// </summary> public bool Equals(TargetPlatformSDK other) { if (other == null) { return(false); } return(TargetPlatformIdentifier.Equals(other.TargetPlatformIdentifier, StringComparison.OrdinalIgnoreCase) && TargetPlatformVersion.Equals(other.TargetPlatformVersion)); }
/// <summary> /// Override GetHashCode /// </summary> public override int GetHashCode() { return(TargetPlatformIdentifier.ToLowerInvariant().GetHashCode() ^ TargetPlatformVersion.GetHashCode()); }
/// <summary> /// Initializes a new instance of the <see cref="TargetPlatform"/> class. /// </summary> /// <param name="platform">The .NET framework target version.</param> public TargetPlatform(TargetPlatformVersion platform) { _platform = platform; }
/// <summary> /// Returns a string value containing the command line arguments to pass directly to the executable file. /// </summary> /// <returns> /// A string value containing the command line arguments to pass directly to the executable file. /// </returns> protected override string GenerateCommandLineCommands() { const string errorReturnValue = ""; if (false == ValidateInputAssemblies() || false == ValidateOutputFile()) { return(errorReturnValue); } #region " ILMerge.exe Command-Line Arguments " /* * [/lib:directory]* * [/log[:filename]] * [/keyfile:filename [/delaysign]] * [/internalize[:filename]] * [/t[arget]:(library|exe|winexe)] * [/closed] * [/ndebug] * [/ver:version] * [/copyattrs [/allowMultiple]] * [/xmldocs] * [/attr:filename] * ([/targetplatform:<version>[,<platformdir>]]|v1|v1.1|v2|v4) * [/useFullPublicKeyForReferences] * [/zeroPeKind] * [/wildcards] * [/allowDup[:typename]]* * [/allowDuplicateResources] * [/union] * [/align:n] * /out:filename * <primary assembly> [<other assemblies>...] */ #endregion " ILMerge.exe Command-Line Arguments " var builder = new CommandLineBuilder(); if (null != DuplicateTypeNames && DuplicateTypeNames.Length > 0) { foreach (var item in DuplicateTypeNames) { var typeName = item.ItemSpec; builder.AppendSwitch(string.Format("/allowDup:{0}", typeName.Trim())); } } else if (AllowDuplicateTypeNames) { builder.AppendSwitch("/allowDup"); } if (AllowMultipleAssemblyLevelAttributes) { builder.AppendSwitch("/allowMultiple"); } if (AllowWildCards) { builder.AppendSwitch("/wildcards"); } if (AllowZeroPeKind) { builder.AppendSwitch("/zeroPeKind"); } if (false == string.IsNullOrWhiteSpace(AttributeFile)) { builder.AppendSwitch(string.Format("/attr:\"{0}\"", AttributeFile.Trim())); } if (Closed) { builder.AppendSwitch("/closed"); } if (CopyAttributes) { builder.AppendSwitch("/copyattrs"); } if (false == DebugInfo) { builder.AppendSwitch("/ndebug"); } if (DelaySign) { builder.AppendSwitch("/delaysign"); } if (FileAlignment != DefaultFileAlignment) { builder.AppendSwitch(string.Format("/align:{0}", FileAlignment)); } if (Internalize) { builder.AppendSwitch(string.Format("/internalize{0}", string.IsNullOrWhiteSpace(ExcludeFile) ? "" : string.Format(":\"{0}\"", ExcludeFile.Trim()))); } if (false == string.IsNullOrWhiteSpace(KeyFile)) { builder.AppendSwitch(string.Format("/keyfile:\"{0}\"", KeyFile.Trim())); } if (false == string.IsNullOrWhiteSpace(LogFile)) { builder.AppendSwitch(string.Format("/log:\"{0}\"", LogFile.Trim())); } if (false == PublicKeyTokens) { builder.AppendSwitch("/useFullPublicKeyForReferences"); } if (null != SearchDirectories && SearchDirectories.Length > 0) { foreach (var item in SearchDirectories) { var directory = item.ItemSpec; builder.AppendSwitch(string.Format("/lib:\"{0}\"", directory.Trim())); } } // Target Platform if (false == string.IsNullOrWhiteSpace(TargetPlatformDirectory) && false == string.IsNullOrWhiteSpace(TargetPlatformVersion)) { var value = string.Format("{0},\"{1}\"", TargetPlatformVersion.Trim().ToLowerInvariant(), TargetPlatformDirectory.Trim()); builder.AppendSwitch(string.Format("/targetplatform:{0}", value)); } if (false == string.IsNullOrWhiteSpace(TargetType)) { builder.AppendSwitch(string.Format("/target:{0}", TargetType.Trim().ToLowerInvariant())); } if (UnionMerge) { builder.AppendSwitch("/union"); } if (XmlDocumentation) { builder.AppendSwitch("/xmldocs"); } if (false == string.IsNullOrWhiteSpace(Version)) { builder.AppendSwitch(string.Format("/ver:{0}", Version.Trim())); } // OutputFile is added after all other switches and before the InputAssemblies. builder.AppendSwitch(string.Format("/out:\"{0}\"", OutputFile)); // InputAssemblies must be added after all other switches. if (null != InputAssemblies && InputAssemblies.Length > 0) { foreach (var inputAssemblyPath in InputAssemblies) { builder.AppendTextUnquoted(string.Format(" \"{0}\"", inputAssemblyPath)); } } return(builder.ToString()); }