diff --git a/ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.csproj b/ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.csproj index 58d6b8a..1802bff 100644 --- a/ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.csproj +++ b/ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.csproj @@ -18,6 +18,7 @@ + diff --git a/ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.props b/ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.props new file mode 100644 index 0000000..d8e77e3 --- /dev/null +++ b/ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.props @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.targets b/ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.targets index 1c6fc63..bbe9132 100644 --- a/ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.targets +++ b/ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.targets @@ -3,11 +3,14 @@ $(ProjectDir)ILRepack.targets + true + false + false + true - - + @@ -26,7 +29,7 @@ + Condition="$(ILRepackEnabled) and $(ClearOutputDirectory)"> diff --git a/ILRepack.Lib.MSBuild.Task/ILRepack.cs b/ILRepack.Lib.MSBuild.Task/ILRepack.cs index 8dc4ba6..32c430a 100644 --- a/ILRepack.Lib.MSBuild.Task/ILRepack.cs +++ b/ILRepack.Lib.MSBuild.Task/ILRepack.cs @@ -19,6 +19,7 @@ public class ILRepack : Microsoft.Build.Utilities.Task, IDisposable private string _keyContainer; private ILRepacking.ILRepack.Kind _targetKind; private string _excludeFileTmpPath; + private MessageImportance _messageImportance = MessageImportance.High; #endregion @@ -51,6 +52,14 @@ public virtual string LogFile set => _logFile = BuildPath(ConvertEmptyToNull(value)); } + /// + /// Specifies the log task messages importance (High by default). + /// + public virtual string LogImportance { + get => _messageImportance.ToString(); + set => Enum.TryParse(value, true, out _messageImportance); + } + /// /// Merges types with identical names into one. /// @@ -300,7 +309,7 @@ public override bool Execute() throw new Exception($"Unable to resolve assembly '{assemblies[i]}'"); } - Log.LogMessage(MessageImportance.High, "Added assembly '{0}'", assemblies[i]); + LogMessage("Added assembly '{0}'", assemblies[i]); } // List of regex to compare against FullName of types NOT to internalize @@ -318,7 +327,7 @@ public override bool Execute() $"Invalid internalize exclude pattern at item index {i}. Pattern cannot be blank."); } - Log.LogMessage(MessageImportance.High, + LogMessage( "Excluding namespaces/types matching pattern '{0}' from being internalized", internalizeExclude[i]); } @@ -348,7 +357,7 @@ public override bool Execute() repackOptions.SearchDirectories = searchPath.ToArray(); // Attempt to merge assemblies. - Log.LogMessage(MessageImportance.High, "Merging {0} assembl{1} to '{2}'", + LogMessage("Merging {0} assembl{1} to '{2}'", InputAssemblies.Length, InputAssemblies.Length != 1 ? "ies" : "y", _outputFile); // Measure performance @@ -365,7 +374,7 @@ public override bool Execute() stopWatch.Stop(); - Log.LogMessage(MessageImportance.High, "Merge succeeded in {0} s", stopWatch.Elapsed.TotalSeconds); + LogMessage("Merge succeeded in {0} s", stopWatch.Elapsed.TotalSeconds); logger.Close(); return true; @@ -379,9 +388,15 @@ public override bool Execute() } } - #endregion - - #region Private methods + /// + /// Logs a message with the specified format and arguments. + /// + /// The message format. + /// The arguments for the message format. + private void LogMessage(string message, params object[] messageArgs) + { + Log.LogMessage(_messageImportance, message, messageArgs); + } /// /// Parses the command line options for AllowedDuplicateNameSpaces. diff --git a/ILRepack.Lib.MSBuild.Task/build/ILRepack.Lib.MSBuild.Task.nuspec b/ILRepack.Lib.MSBuild.Task/build/ILRepack.Lib.MSBuild.Task.nuspec index 83d4682..ef851ba 100644 --- a/ILRepack.Lib.MSBuild.Task/build/ILRepack.Lib.MSBuild.Task.nuspec +++ b/ILRepack.Lib.MSBuild.Task/build/ILRepack.Lib.MSBuild.Task.nuspec @@ -19,6 +19,7 @@ + diff --git a/README.md b/README.md index 043f895..b780ff3 100644 --- a/README.md +++ b/README.md @@ -80,13 +80,22 @@ option only applies if you are using default targets file provided in NuGet pack $(ProjectDir)ILRepack.snk ``` +### Disable default ILRepack Target + +By default if no "ILRepack.targets" file is found a default ILRepack Target runs after build if the configuration contains "Release". +You can disable this behavior by setting the following property to `false` or `true` to enable it. + +```xml +false +``` + ### Specify whether to clear directory after merging If you are using default targets file then you may notice that it clears Output directory after merging dependencies. You can turn this functionality off by setting ClearOutputDirectory to False as shown below. ```xml -False +false ``` ## Task options @@ -109,6 +118,7 @@ You can turn this functionality off by setting ClearOutputDirectory to False as | KeyFile | Specifies a key file to sign the output assembly. | | LibraryPath | List of paths to use as "include directories" when attempting to merge assemblies. | | LogFile | Specifies a log file to output log information. | +| LogImportance | Specifies the log message importance in the task. (`high` by default, `normal` and `low` available) | | MergeIlLinkerFiles | Merge IL Linker file XML resources from Microsoft assemblies (optional). Same-named XML resources ('ILLink.*.xml') will be combined during merging. | | NoRepackRes | Does not add the embedded resource 'ILRepack.List' with all merged assembly names. | | OutputFile | Output name for the merged assembly. |