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; }
|
||||
|
||||
/// <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()
|
||||
{
|
||||
if (ReplacementItems == null && ReplacementPatterns == null && ReplacementStrings == null)
|
||||
|
@ -81,6 +86,12 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
public void ReplaceContents(string inputFile, string destinationFile)
|
||||
{
|
||||
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);
|
||||
|
||||
WriteOutputFile(destinationFile, outputFileText);
|
||||
|
|
|
@ -403,15 +403,27 @@
|
|||
<PropertyGroup>
|
||||
<ReplacementPattern>"version": ".*"</ReplacementPattern>
|
||||
<ReplacementString>"version": "$(MicrosoftNETCoreAppRuntimePackageVersion)"</ReplacementString>
|
||||
<AspNetCoreRuntimeReplacementString>"version": "$(MicrosoftAspNetCoreAppRuntimePackageVersion)"</AspNetCoreRuntimeReplacementString>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ToolRuntimeConfigPath Include="$(RedistLayoutPath)sdk/$(Version)/**/*.runtimeconfig.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Update runtimeconfig files that target Microsoft.NETCore.App -->
|
||||
<ReplaceFileContents
|
||||
InputFiles="@(ToolRuntimeConfigPath)"
|
||||
DestinationFiles="@(ToolRuntimeConfigPath)"
|
||||
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 Name="GenerateVersionFile"
|
||||
|
|
Loading…
Add table
Reference in a new issue