Skip to content

Commit 10ee7cd

Browse files
authored
Replace ASP.NET Core version-fix patch with source-mutation (#2005)
See: #1644
1 parent 79a4f33 commit 10ee7cd

File tree

5 files changed

+72
-24
lines changed

5 files changed

+72
-24
lines changed

.github/ISSUE_TEMPLATE/releases/release_checklist.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- [3.1 / 5.0]
3838
- [ ] Verify that the `PrivateSourceBuiltArtifactsPackageVersion` in `eng/Versions.props` matches N-1 release artifacts.
3939
- [ ] Update the `global.json` SDK version to N-1: the latest released "3.1.XYY" SDK version, where "3.1.X" matches the SDK we're building.
40+
- [ ] Update the `eng/Versions.props` with the latest product versions.
4041
1. - [ ] [2.1] Fetch internal git data for submodules.
4142
1. Run `git submodule update --init --recursive` and see errors due to missing commits.
4243
1. Run `fetch-vsts-commits.sh` with a PAT to automatically fetch internal refs.

eng/Versions.props

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<!-- SDK/Runtime Version Information -->
4+
<PropertyGroup>
5+
<MajorVersion>5</MajorVersion>
6+
<MinorVersion>0</MinorVersion>
7+
<RuntimePatchVersion>2</RuntimePatchVersion>
8+
<SdkPatchVersion>102</SdkPatchVersion>
9+
<RuntimeProductVersion>$(MajorVersion).$(MinorVersion).$(RuntimePatchVersion)</RuntimeProductVersion>
10+
<AspNetCoreProductVersion>$(MajorVersion).$(MinorVersion).$(RuntimePatchVersion)</AspNetCoreProductVersion>
11+
<SdkProductVersion>$(MajorVersion).$(MinorVersion).$(SdkPatchVersion)</SdkProductVersion>
12+
</PropertyGroup>
13+
314
<!-- Repo Version Information -->
415
<PropertyGroup>
516
<VersionPrefix>0.1.0</VersionPrefix>

patches/aspnetcore/0016-Fix-version-number.patch

Lines changed: 0 additions & 24 deletions
This file was deleted.

repos/aspnetcore.proj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,27 @@
6565
<EnvironmentVariables Include="DotNetPackageVersionPropsPath=$(PackageVersionPropsPath)" />
6666
</ItemGroup>
6767

68+
<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="ReplaceRegexInFiles" />
69+
70+
<Target Name="FixAspNetCoreVersion"
71+
AfterTargets="ApplyPatches">
72+
73+
<ItemGroup>
74+
<MinifiedJavascriptFile Include="$(ProjectDirectory)**\blazor.server.js" />
75+
</ItemGroup>
76+
77+
<!--
78+
Patch the version embedded in minified js files. Because they are
79+
minified files, git patch doesn't work too well and produces unreadable
80+
binary patches.
81+
-->
82+
<ReplaceRegexInFiles
83+
InputFiles="@(MinifiedJavascriptFile)"
84+
OldTextRegex=",l=&quot;5\.0\.\d+&quot;}]\);"
85+
NewText=",l=&quot;$(AspNetCoreProductVersion)&quot;}]);" />
86+
87+
</Target>
88+
6889
<Target Name="SetOutputList" AfterTargets="Package" BeforeTargets="GatherBuiltPackages">
6990
<ItemGroup>
7091
<PackagesOutputList Include="$(ShippingPackagesOutput)" />
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.IO;
7+
using System.Text.RegularExpressions;
8+
using Microsoft.Build.Framework;
9+
using Microsoft.Build.Utilities;
10+
11+
namespace Microsoft.DotNet.Build.Tasks
12+
{
13+
public class ReplaceRegexInFiles : Task
14+
{
15+
[Required]
16+
public string[] InputFiles { get; set; }
17+
18+
[Required]
19+
public string OldTextRegex { get; set; }
20+
21+
[Required]
22+
public string NewText { get; set; }
23+
24+
public override bool Execute()
25+
{
26+
Log.LogMessage($"Replacing '{OldTextRegex}' with '{NewText}'");
27+
foreach (string file in InputFiles)
28+
{
29+
string fileContents = File.ReadAllText(file);
30+
31+
fileContents = Regex.Replace(fileContents, OldTextRegex, NewText);
32+
33+
File.WriteAllText(file, fileContents);
34+
}
35+
36+
return true;
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)