Stamp runtimeconfigs with M.AspNetCore.App versions
The installer currently updates all runtimeconfig files with the M.NETCore.App version regardless of the runtime they are targeting. This causes issues with dotnet-watch which is targeting the AspNetCore shared runtime as of 5.0-preview8. This change updates the targets \ task to be more discerning.
This commit is contained in:
parent
03c8593ee0
commit
45264fac2a
2 changed files with 31 additions and 8 deletions
|
@ -40,6 +40,11 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
|
|
||||||
public ITaskItem[] ReplacementStrings { get; set; }
|
public ITaskItem[] ReplacementStrings { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a string that a file must contain for the replacement to be performed.
|
||||||
|
/// </summary>
|
||||||
|
public string FileMustContainText { get; set; }
|
||||||
|
|
||||||
public override bool Execute()
|
public override bool Execute()
|
||||||
{
|
{
|
||||||
if (ReplacementItems == null && ReplacementPatterns == null && ReplacementStrings == null)
|
if (ReplacementItems == null && ReplacementPatterns == null && ReplacementStrings == null)
|
||||||
|
@ -81,6 +86,12 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
public void ReplaceContents(string inputFile, string destinationFile)
|
public void ReplaceContents(string inputFile, string destinationFile)
|
||||||
{
|
{
|
||||||
string inputFileText = File.ReadAllText(inputFile);
|
string inputFileText = File.ReadAllText(inputFile);
|
||||||
|
if (!string.IsNullOrEmpty(FileMustContainText) && !inputFileText.Contains(FileMustContainText))
|
||||||
|
{
|
||||||
|
Log.LogMessage(MessageImportance.Low, $"Skipping replacement on `{inputFile}` because it does not contain the text '{FileMustContainText}'.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string outputFileText = ReplacePatterns(inputFileText);
|
string outputFileText = ReplacePatterns(inputFileText);
|
||||||
|
|
||||||
WriteOutputFile(destinationFile, outputFileText);
|
WriteOutputFile(destinationFile, outputFileText);
|
||||||
|
|
|
@ -403,15 +403,27 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ReplacementPattern>"version": ".*"</ReplacementPattern>
|
<ReplacementPattern>"version": ".*"</ReplacementPattern>
|
||||||
<ReplacementString>"version": "$(MicrosoftNETCoreAppRuntimePackageVersion)"</ReplacementString>
|
<ReplacementString>"version": "$(MicrosoftNETCoreAppRuntimePackageVersion)"</ReplacementString>
|
||||||
|
<AspNetCoreRuntimeReplacementString>"version": "$(MicrosoftAspNetCoreAppRuntimePackageVersion)"</AspNetCoreRuntimeReplacementString>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ToolRuntimeConfigPath Include="$(RedistLayoutPath)sdk/$(Version)/**/*.runtimeconfig.json" />
|
<ToolRuntimeConfigPath Include="$(RedistLayoutPath)sdk/$(Version)/**/*.runtimeconfig.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Update runtimeconfig files that target Microsoft.NETCore.App -->
|
||||||
<ReplaceFileContents
|
<ReplaceFileContents
|
||||||
InputFiles="@(ToolRuntimeConfigPath)"
|
InputFiles="@(ToolRuntimeConfigPath)"
|
||||||
DestinationFiles="@(ToolRuntimeConfigPath)"
|
DestinationFiles="@(ToolRuntimeConfigPath)"
|
||||||
ReplacementPatterns="$(ReplacementPattern)"
|
ReplacementPatterns="$(ReplacementPattern)"
|
||||||
ReplacementStrings="$(ReplacementString)" />
|
ReplacementStrings="$(ReplacementString)"
|
||||||
|
FileMustContainText="Microsoft.NETCore.App" />
|
||||||
|
|
||||||
|
<!-- Update runtimeconfig files that target Microsoft.AspNetCore.App -->
|
||||||
|
<ReplaceFileContents
|
||||||
|
InputFiles="@(ToolRuntimeConfigPath)"
|
||||||
|
DestinationFiles="@(ToolRuntimeConfigPath)"
|
||||||
|
ReplacementPatterns="$(ReplacementPattern)"
|
||||||
|
ReplacementStrings="$(AspNetCoreRuntimeReplacementString)"
|
||||||
|
FileMustContainText="Microsoft.AspNetCore.App" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="GenerateVersionFile"
|
<Target Name="GenerateVersionFile"
|
||||||
|
|
Loading…
Add table
Reference in a new issue