Skip to content

Replace ASP.NET Core version-fix patch with source-mutation #2005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/releases/release_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- [3.1 / 5.0]
- [ ] Verify that the `PrivateSourceBuiltArtifactsPackageVersion` in `eng/Versions.props` matches N-1 release artifacts.
- [ ] 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.
- [ ] Update the `eng/Versions.props` with the latest product versions.
1. - [ ] [2.1] Fetch internal git data for submodules.
1. Run `git submodule update --init --recursive` and see errors due to missing commits.
1. Run `fetch-vsts-commits.sh` with a PAT to automatically fetch internal refs.
Expand Down
11 changes: 11 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- SDK/Runtime Version Information -->
<PropertyGroup>
<MajorVersion>5</MajorVersion>
<MinorVersion>0</MinorVersion>
<RuntimePatchVersion>2</RuntimePatchVersion>
<SdkPatchVersion>102</SdkPatchVersion>
<RuntimeProductVersion>$(MajorVersion).$(MinorVersion).$(RuntimePatchVersion)</RuntimeProductVersion>
<AspNetCoreProductVersion>$(MajorVersion).$(MinorVersion).$(RuntimePatchVersion)</AspNetCoreProductVersion>
<SdkProductVersion>$(MajorVersion).$(MinorVersion).$(SdkPatchVersion)</SdkProductVersion>
</PropertyGroup>

<!-- Repo Version Information -->
<PropertyGroup>
<VersionPrefix>0.1.0</VersionPrefix>
Expand Down
24 changes: 0 additions & 24 deletions patches/aspnetcore/0016-Fix-version-number.patch

This file was deleted.

21 changes: 21 additions & 0 deletions repos/aspnetcore.proj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,27 @@
<EnvironmentVariables Include="DotNetPackageVersionPropsPath=$(PackageVersionPropsPath)" />
</ItemGroup>

<UsingTask AssemblyFile="$(XPlatSourceBuildTasksAssembly)" TaskName="ReplaceRegexInFiles" />

<Target Name="FixAspNetCoreVersion"
AfterTargets="ApplyPatches">

<ItemGroup>
<MinifiedJavascriptFile Include="$(ProjectDirectory)**\blazor.server.js" />
</ItemGroup>

<!--
Patch the version embedded in minified js files. Because they are
minified files, git patch doesn't work too well and produces unreadable
binary patches.
-->
<ReplaceRegexInFiles
InputFiles="@(MinifiedJavascriptFile)"
OldTextRegex=",l=&quot;5\.0\.\d+&quot;}]\);"
NewText=",l=&quot;$(AspNetCoreProductVersion)&quot;}]);" />

</Target>

<Target Name="SetOutputList" AfterTargets="Package" BeforeTargets="GatherBuiltPackages">
<ItemGroup>
<PackagesOutputList Include="$(ShippingPackagesOutput)" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Microsoft.DotNet.Build.Tasks
{
public class ReplaceRegexInFiles : Task
{
[Required]
public string[] InputFiles { get; set; }

[Required]
public string OldTextRegex { get; set; }

[Required]
public string NewText { get; set; }

public override bool Execute()
{
Log.LogMessage($"Replacing '{OldTextRegex}' with '{NewText}'");
foreach (string file in InputFiles)
{
string fileContents = File.ReadAllText(file);

fileContents = Regex.Replace(fileContents, OldTextRegex, NewText);

File.WriteAllText(file, fileContents);
}

return true;
}
}
}