Merge pull request #5823 from eerhardt/Add11Platforms_101
Fix Ubuntu16.10 BuildSdkDeb
This commit is contained in:
commit
6f6ae43a93
2 changed files with 26 additions and 5 deletions
|
@ -45,8 +45,7 @@
|
|||
<ReplaceFileContents
|
||||
InputFile="$(DebianConfigTemplateFile)"
|
||||
DestinationFile="$(DebianConfigJsonFile)"
|
||||
ReplacementPatterns="@(DebianConfigTokenValues -> '%(Identity)')"
|
||||
ReplacementStrings="@(DebianConfigTokenValues -> '%(ReplacementString)')" />
|
||||
ReplacementItems="@(DebianConfigTokenValues)" />
|
||||
|
||||
<!-- Build SDK Deb package -->
|
||||
<DotNetDebTool ToolPath="$(Stage0Directory)"
|
||||
|
|
|
@ -9,7 +9,12 @@ using Microsoft.Build.Framework;
|
|||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads contents of an input file, and searches for each ReplacementPattern passed in.
|
||||
/// Reads contents of an input file, and searches for each replacement passed in.
|
||||
///
|
||||
/// When ReplacementItems is matched, it will replace the Include/ItemSpec with the corresponding
|
||||
/// ReplacementString metadata value. This can be useful if the ReplacementString is a value that
|
||||
/// cannot be represented by ITaskItem.ItemSpec (like string.Empty).
|
||||
///
|
||||
/// When a ReplacementPattern is matched it will replace it with the string of the corresponding (by index)
|
||||
/// item in ReplacementStrings.
|
||||
///
|
||||
|
@ -27,14 +32,23 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[Required]
|
||||
public string DestinationFile { get; set; }
|
||||
|
||||
[Required]
|
||||
public ITaskItem[] ReplacementItems { get; set; }
|
||||
|
||||
public ITaskItem[] ReplacementPatterns { get; set; }
|
||||
|
||||
[Required]
|
||||
public ITaskItem[] ReplacementStrings { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
if (ReplacementItems == null && ReplacementPatterns == null && ReplacementStrings == null)
|
||||
{
|
||||
throw new Exception($"ReplaceFileContents was called with no replacement values. Either pass ReplacementItems or ReplacementPatterns/ReplacementStrings properties.");
|
||||
}
|
||||
|
||||
ReplacementItems = ReplacementItems ?? Array.Empty<ITaskItem>();
|
||||
ReplacementPatterns = ReplacementPatterns ?? Array.Empty<ITaskItem>();
|
||||
ReplacementStrings = ReplacementStrings ?? Array.Empty<ITaskItem>();
|
||||
|
||||
if (ReplacementPatterns.Length != ReplacementStrings.Length)
|
||||
{
|
||||
throw new Exception($"Expected {nameof(ReplacementPatterns)} (length {ReplacementPatterns.Length}) and {nameof(ReplacementStrings)} (length {ReplacementStrings.Length}) to have the same length.");
|
||||
|
@ -57,6 +71,14 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
{
|
||||
var outText = inputFileText;
|
||||
|
||||
foreach (var replacementItem in ReplacementItems)
|
||||
{
|
||||
var replacementPattern = replacementItem.ItemSpec;
|
||||
var replacementString = replacementItem.GetMetadata("ReplacementString");
|
||||
|
||||
outText = outText.Replace(replacementPattern, replacementString);
|
||||
}
|
||||
|
||||
for (int i=0; i<ReplacementPatterns.Length; ++i)
|
||||
{
|
||||
var replacementPattern = ReplacementPatterns[i].ItemSpec;
|
||||
|
|
Loading…
Reference in a new issue