Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions NetRevisionTask/AssemblyInfoHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public AssemblyInfoHelper(string projectDir, bool throwOnMissingFile, ILogger lo
/// <param name="revOnly">Indicates whether only the last number is replaced by the revision number.</param>
/// <param name="copyrightAttribute">Indicates whether the copyright year is replaced.</param>
/// <param name="echo">Indicates whether the final informational version string is displayed.</param>
/// <param name="processAnyProperty">Indicates wheter all properties should be processed.</param>
/// <returns>The name of the patched AssemblyInfo file.</returns>
public string PatchFile(
string patchedFileDir,
Expand All @@ -87,7 +88,8 @@ public string PatchFile(
bool informationalAttribute,
bool revOnly,
bool copyrightAttribute,
bool echo)
bool echo,
bool processAnyProperty)
{
logger?.Trace($@"Patching file ""{fileName}""...");
ReadFileLines(FullFileName);
Expand All @@ -111,7 +113,7 @@ public string PatchFile(
}

// Process all lines in the file
ResolveAllLines(rf, simpleAttributes, informationalAttribute, revOnly, copyrightAttribute, echo);
ResolveAllLines(rf, simpleAttributes, informationalAttribute, revOnly, copyrightAttribute, echo, processAnyProperty);

// Write all lines to the file
string patchedFileName = Path.Combine(patchedFileDir, "Nrt" + Path.GetFileName(fileName));
Expand Down Expand Up @@ -250,7 +252,8 @@ private void WriteFileLines(string patchedFileName)
/// <param name="revOnly">Indicates whether only the last number is replaced by the revision number.</param>
/// <param name="copyrightAttribute">Indicates whether the copyright year is replaced.</param>
/// <param name="echo">Indicates whether the final informational version string is displayed.</param>
private void ResolveAllLines(RevisionFormatter rf, bool simpleAttributes, bool informationalAttribute, bool revOnly, bool copyrightAttribute, bool echo)
/// <param name="processAnyProperty">Indicates wheter all properties should be processed.</param>
private void ResolveAllLines(RevisionFormatter rf, bool simpleAttributes, bool informationalAttribute, bool revOnly, bool copyrightAttribute, bool echo, bool processAnyProperty)
{
// Preparing a truncated dotted-numeric version if we may need it
string truncVersion = null;
Expand Down Expand Up @@ -385,6 +388,16 @@ private void ResolveAllLines(RevisionFormatter rf, bool simpleAttributes, bool i
logger?.Trace($@" Replaced ""{match.Groups[2].Value}"" with ""{copyrightText}"".");
}
}

if (processAnyProperty && !string.IsNullOrEmpty(lines[i]))
{
string newline = rf.Resolve(lines[i]);
if(newline != lines[i])
{
lines[i] = newline;
logger?.Trace($@" Replaced ""{lines[i]}"" with ""{newline}"".");
}
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion NetRevisionTask/Tasks/PatchAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public class PatchAssemblyInfo : MSBuildTask
/// </summary>
public bool ShowRevision { get; set; }

/// <summary>
/// Gets or sets a value indicating whether all properties are processed.
/// </summary>
public bool ProcessAnyProperty { get; set; }

#endregion Properties

#region Task output properties
Expand Down Expand Up @@ -157,7 +162,8 @@ public override bool Execute()
ResolveInformationalAttribute,
RevisionNumberOnly,
ResolveCopyright,
ShowRevision);
ShowRevision,
ProcessAnyProperty);
}
catch (FormatException ex)
{
Expand Down
5 changes: 5 additions & 0 deletions NetRevisionTask/Tasks/SetVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public class SetVersion : MSBuildTask
/// </summary>
public bool ShowRevision { get; set; }

/// <summary>
/// Gets or sets a value indicating whether all properties are processed.
/// </summary>
public bool ProcessAnyProperty { get; set; }

#endregion Properties

#region Task output properties
Expand Down
7 changes: 5 additions & 2 deletions NetRevisionTask/build/Unclassified.NetRevisionTask.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<NrtResolveCopyright Condition="'$(NrtResolveCopyright)' == ''">true</NrtResolveCopyright>
<NrtTagMatch Condition="'$(NrtTagMatch)' == ''">v[0-9]*</NrtTagMatch>
<NrtRemoveTagV Condition="'$(NrtRemoveTagV)' == ''">true</NrtRemoveTagV>
<NrtProcessAnyProperty Condition="'$(NrtProcessAnyProperty)' == ''">false</NrtProcessAnyProperty>
</PropertyGroup>
</Target>

Expand All @@ -31,7 +32,8 @@
RemoveTagV="$(NrtRemoveTagV)"
ResolveCopyright="$(NrtResolveCopyright)"
Copyright="$(Copyright)"
ShowRevision="$(NrtShowRevision)">
ShowRevision="$(NrtShowRevision)"
ProcessAnyProperty="$(NrtProcessAnyProperty)">
<Output TaskParameter="Version" PropertyName="Version"/>
<Output TaskParameter="InformationalVersion" PropertyName="InformationalVersion"/>
<Output TaskParameter="Copyright" PropertyName="Copyright"/>
Expand Down Expand Up @@ -66,7 +68,8 @@
ResolveInformationalAttribute="$(NrtResolveInformationalAttribute)"
RevisionNumberOnly="$(NrtRevisionNumberOnly)"
ResolveCopyright="$(NrtResolveCopyright)"
ShowRevision="$(NrtShowRevision)">
ShowRevision="$(NrtShowRevision)"
ProcessAnyProperty="$(NrtProcessAnyProperty)">
<Output TaskParameter="SourceAssemblyInfo" PropertyName="NrtSourceAssemblyInfo"/>
<Output TaskParameter="PatchedAssemblyInfo" PropertyName="NrtPatchedAssemblyInfo"/>
</PatchAssemblyInfo>
Expand Down