Skip to content
Merged
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Extensions.AI.Templates.IntegrationTests;
using Microsoft.Extensions.AI.Templates.Tests;
Expand Down Expand Up @@ -31,6 +32,10 @@ public class AichatwebTemplatesTests : TestBase
"**/Directory.Build.targets",
];

private static readonly string[] _packagePrefixesWithJustBuiltVersionNumber = [
"Microsoft.Extensions.AI",
];

private readonly ILogger _log;

public AichatwebTemplatesTests(ITestOutputHelper log)
Expand Down Expand Up @@ -71,7 +76,16 @@ public async Task BasicTest()
filePath.EndsWith("aichatweb/aichatweb.csproj.in"))
{
content.ScrubByRegex("<UserSecretsId>(.*)<\\/UserSecretsId>", "<UserSecretsId>secret</UserSecretsId>");
content.ScrubByRegex("\"(\\d*\\.\\d*\\.\\d*)-(dev|ci)\"", "\"$1\"");

foreach (var prefix in _packagePrefixesWithJustBuiltVersionNumber)
{
// Scrub references to just-built packages and remove the suffix, if it exists.
// This allows the snapshots to remain the same regardless of where the repo is built (e.g., locally, public CI, internal CI).
var escapedPrefix = Regex.Escape(prefix);
var pattern = $"<PackageReference\\s+Include=\\\"({escapedPrefix}[^\"]*)\\\"\\s+Version=\\\"([^{{\\\"|\\-}}]*)[^\"]*\\\"\\s*\\/>";
var replacement = "<PackageReference Include=\"$1\" Version=\"$2\" />";
content.ScrubByRegex(pattern, replacement);
}
}

if (filePath.EndsWith("aichatweb/Properties/launchSettings.json"))
Expand Down
Loading