Generating the conclusion.html files dynamically so that we don't need to set the version in them everytime our branding changes.

This commit is contained in:
Livar Cunha 2018-04-04 20:57:45 -07:00
parent f496a9bb18
commit b09b6bff26
21 changed files with 111 additions and 72 deletions

View file

@ -53,8 +53,8 @@
<!-- Create layout: Generate and Place postinst -->
<ReplaceFileContents
InputFile="$(DebianPostinstTemplateFile)"
DestinationFile="$(DebianPostinstFile)"
InputFiles="$(DebianPostinstTemplateFile)"
DestinationFiles="$(DebianPostinstFile)"
ReplacementItems="@(DebianPostInstTokenValues)" />
<Chmod
@ -63,8 +63,8 @@
<!-- Create layout: Generate and Place debian_config.json -->
<ReplaceFileContents
InputFile="$(DebianConfigTemplateFile)"
DestinationFile="$(DebianConfigJsonFile)"
InputFiles="$(DebianConfigTemplateFile)"
DestinationFiles="$(DebianConfigJsonFile)"
ReplacementItems="@(DebianConfigTokenValues)" />
<Chmod

View file

@ -155,8 +155,8 @@
'$(NugetVersion)'
'$(CombinedFrameworkSDKHostInstallerUpgradeCode)'
'$(Architecture)'
'$(SharedFrameworkVersion)'
'$(AspNetCoreRuntimePackageVersion)'" />
'$(MicrosoftNETCoreAppPackageVersion)'
'$(AspNetCoreVersion)'" />
</Target>
<Target Name="GenerateSdkNupkg"

View file

@ -17,7 +17,7 @@
<SdkPkgScriptTemplateFile>$(SdkPkgScriptsDirectory)/postinstall</SdkPkgScriptTemplateFile>
<SdkPkgDestinationScriptsDirectory>$(PkgIntermediateDirectory)/scripts</SdkPkgDestinationScriptsDirectory>
<SdkPkgScriptFile>$(SdkPkgDestinationScriptsDirectory)/postinstall</SdkPkgScriptFile>
<SdkProductArchiveResourcesDirectory>$(SdkPkgSourcesRootDirectory)/resources</SdkProductArchiveResourcesDirectory>
<SdkProductArchiveResourcesDirectory>$(PkgIntermediateDirectory)/resources</SdkProductArchiveResourcesDirectory>
<SdkProductArchiveDistributionTemplateFile>$(SdkPkgSourcesRootDirectory)/Distribution-Template</SdkProductArchiveDistributionTemplateFile>
<SdkProductArchiveDistributionFile>$(PkgIntermediateDirectory)/CLI-SDK-Formatted-Distribution-Template.xml</SdkProductArchiveDistributionFile>
@ -61,6 +61,16 @@
<PostInstallScriptReplacement Include="%SDK_VERSION%">
<ReplacementString>$(SdkVersion)</ReplacementString>
</PostInstallScriptReplacement>
<ResourcesReplacement Include="{DOTNETSDKVERSION}">
<ReplacementString>$(SdkVersion)</ReplacementString>
</ResourcesReplacement>
<ResourcesReplacement Include="{DOTNETRUNTIMEVERSION}">
<ReplacementString>$(MicrosoftNETCoreAppPackageVersion)</ReplacementString>
</ResourcesReplacement>
<ResourcesReplacement Include="{ASPNETCOREVERSION}">
<ReplacementString>$(AspNetCoreVersion)</ReplacementString>
</ResourcesReplacement>
</ItemGroup>
<!-- Consumed By Publish -->
@ -69,6 +79,8 @@
</ItemGroup>
<ItemGroup>
<SdkProductArchiveResourcesTemplateFiles Include="$(SdkPkgSourcesRootDirectory)/resources/**/*" />
<GenerateSdkPkgInputs Include="$(SdkLayoutOutputDirectory)/**/*" />
<GenerateSdkPkgInputs Include="$(SdkPkgScriptsDirectory)/**/*" />
@ -77,7 +89,7 @@
<GenerateSdkProductArchiveInputs Include="$(DownloadedHostFxrInstallerFile)" />
<GenerateSdkProductArchiveInputs Include="$(DownloadedSharedHostInstallerFile)" />
<GenerateSdkProductArchiveInputs Include="$(SdkProductArchiveDistributionTemplateFile)" />
<GenerateSdkProductArchiveInputs Include="$(SdkProductArchiveResourcesDirectory)/**/*" />
<GenerateSdkProductArchiveInputs Include="@(SdkProductArchiveResourcesTemplateFiles)" />
</ItemGroup>
</Target>
@ -91,11 +103,17 @@
DestinationFiles="@(AspNetRuntimeFilesInput->'$(SdkLayoutOutputDirectory)/%(RecursiveDir)%(FileName)%(Extension)')" />
<ReplaceFileContents
InputFile="$(SdkPkgScriptTemplateFile)"
DestinationFile="$(SdkPkgScriptFile)"
InputFiles="$(SdkPkgScriptTemplateFile)"
DestinationFiles="$(SdkPkgScriptFile)"
ReplacementPatterns="@(PostInstallScriptReplacement -> '%(Identity)')"
ReplacementStrings="@(PostInstallScriptReplacement -> '%(ReplacementString)')" />
<ReplaceFileContents
InputFiles="@(SdkProductArchiveResourcesTemplateFiles)"
DestinationFiles="@(SdkProductArchiveResourcesTemplateFiles -> '$(SdkProductArchiveResourcesDirectory)/%(RecursiveDir)%(Filename)%(Extension)')"
ReplacementPatterns="@(ResourcesReplacement -> '%(Identity)')"
ReplacementStrings="@(ResourcesReplacement -> '%(ReplacementString)')" />
<Chmod
Glob="$(SdkPkgScriptFile)"
Mode="ugo+x" />
@ -130,8 +148,8 @@
<!-- Fill out parameters in the Distribution Template -->
<ReplaceFileContents
InputFile="$(SdkProductArchiveDistributionTemplateFile)"
DestinationFile="$(SdkProductArchiveDistributionFile)"
InputFiles="$(SdkProductArchiveDistributionTemplateFile)"
DestinationFiles="$(SdkProductArchiveDistributionFile)"
ReplacementPatterns="@(DistributionTemplateReplacement -> '%(Identity)')"
ReplacementStrings="@(DistributionTemplateReplacement -> '%(ReplacementString)')" />

View file

@ -104,8 +104,8 @@
<GeneratedInstallers Include="$(SdkInstallerFile)" />
</ItemGroup>
<ReplaceFileContents InputFile="$(AfterInstallHostScriptTemplateFile)"
DestinationFile="$(AfterInstallHostScriptDestinationFile)"
<ReplaceFileContents InputFiles="$(AfterInstallHostScriptTemplateFile)"
DestinationFiles="$(AfterInstallHostScriptDestinationFile)"
ReplacementItems="@(AfterInstallHostTokenValue)"/>
<Chmod

View file

@ -9,8 +9,8 @@
<Message Text="$(VersionBadge)" />
<ReplaceFileContents
InputFile="$(VersionSvgTemplate)"
DestinationFile="$(VersionBadge)"
InputFiles="$(VersionSvgTemplate)"
DestinationFiles="$(VersionBadge)"
ReplacementPatterns="ver_number"
ReplacementStrings="$(SdkVersion)" />
</Target>
@ -21,8 +21,8 @@
<Message Text="$(CoherentBadge)" />
<ReplaceFileContents
InputFile="$(VersionSvgTemplate)"
DestinationFile="$(CoherentBadge)"
InputFiles="$(VersionSvgTemplate)"
DestinationFiles="$(CoherentBadge)"
ReplacementPatterns="ver_number"
ReplacementStrings="$(SdkVersion)" />
</Target>

View file

@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
@ -28,10 +29,10 @@ namespace Microsoft.DotNet.Cli.Build
public class ReplaceFileContents : Task
{
[Required]
public string InputFile { get; set; }
public ITaskItem[] InputFiles { get; set; }
[Required]
public string DestinationFile { get; set; }
public ITaskItem[] DestinationFiles { get; set; }
public ITaskItem[] ReplacementItems { get; set; }
@ -55,19 +56,36 @@ namespace Microsoft.DotNet.Cli.Build
throw new Exception($"Expected {nameof(ReplacementPatterns)} (length {ReplacementPatterns.Length}) and {nameof(ReplacementStrings)} (length {ReplacementStrings.Length}) to have the same length.");
}
if (!File.Exists(InputFile))
if (InputFiles.Length != DestinationFiles.Length)
{
throw new FileNotFoundException($"Expected file {InputFile} was not found.");
throw new Exception($"Expected {nameof(InputFiles)} (length {InputFiles.Length}) and {nameof(DestinationFiles)} (length {DestinationFiles.Length}) to have the same length.");
}
string inputFileText = File.ReadAllText(InputFile);
string outputFileText = ReplacePatterns(inputFileText);
var filesNotFound = InputFiles.Where(i => !File.Exists(i.ItemSpec)).Select(i => i.ItemSpec);
if (filesNotFound.Any())
{
var filesNotFoundString = string.Join(",", filesNotFound);
throw new FileNotFoundException($"Expected files where not found: {filesNotFoundString}");
}
WriteOutputFile(outputFileText);
Log.LogMessage(MessageImportance.High, $"ReplacingContents for `{InputFiles.Length}` files.");
for (var i = 0; i < InputFiles.Length; i++)
{
ReplaceContents(InputFiles[i].ItemSpec, DestinationFiles[i].ItemSpec);
}
return true;
}
public void ReplaceContents(string inputFile, string destinationFile)
{
string inputFileText = File.ReadAllText(inputFile);
string outputFileText = ReplacePatterns(inputFileText);
WriteOutputFile(destinationFile, outputFileText);
}
public string ReplacePatterns(string inputFileText)
{
var outText = inputFileText;
@ -92,15 +110,18 @@ namespace Microsoft.DotNet.Cli.Build
return outText;
}
public void WriteOutputFile(string outputFileText)
public void WriteOutputFile(string destinationFile, string outputFileText)
{
var destinationDirectory = Path.GetDirectoryName(DestinationFile);
var destinationDirectory = Path.GetDirectoryName(destinationFile);
Log.LogMessage(MessageImportance.High, $"Destination Directory: {destinationDirectory}");
if (!Directory.Exists(destinationDirectory))
{
Log.LogMessage(MessageImportance.High, $"Destination Directory `{destinationDirectory}` does not exist. Creating...");
Directory.CreateDirectory(destinationDirectory);
}
File.WriteAllText(DestinationFile, outputFileText);
Log.LogMessage(MessageImportance.High, $"Writing file: {destinationFile}");
File.WriteAllText(destinationFile, outputFileText);
}
}
}

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -7,9 +7,9 @@
<div align="left" style="font-family: Helvetica;padding-left:10px">
<p>The following was installed at /usr/local/share/dotnet</h2>
<ul>
<li>.NET Core SDK 2.1.300</li>
<li>.NET Core Runtime 2.1.0</li>
<li>ASP.NET Core Runtime 2.1.0</li>
<li>.NET Core SDK {DOTNETSDKVERSION}</li>
<li>.NET Core Runtime {DOTNETRUNTIMEVERSION}</li>
<li>ASP.NET Core Runtime {ASPNETCOREVERSION}</li>
</ul>
</div>
<br>

View file

@ -356,8 +356,8 @@
<ReplacementString>"version": "$(MicrosoftNETCoreAppPackageVersion)"</ReplacementString>
</PropertyGroup>
<ReplaceFileContents
InputFile="$(VSTestRuntimeConfigPath)"
DestinationFile="$(VSTestRuntimeConfigPath)"
InputFiles="$(VSTestRuntimeConfigPath)"
DestinationFiles="$(VSTestRuntimeConfigPath)"
ReplacementPatterns="$(ReplacementPattern)"
ReplacementStrings="$(ReplacementString)" />
</Target>