Skip to content

Commit a63d9bb

Browse files
Fix chat template test version scrubbing (#6140)
Fixes an issue where versions in package references to just-built packages were not always being scrubbed correctly. Prior to this PR, specific version suffixes (-ci, -dev) were scrubbed, but this new PR takes a more robust approach that looks for <PackageReference /> items to just-built packages and scrubs the suffix of the Version attribute. There's a static field _packagePrefixesWithJustBuiltVersionNumber that can be extended with more package prefixes that are expected to have a just-built version number. If we're willing to be less conservative, we could even go even further and scrub any references to Microsoft.Extensions.* packages. Fixes #6128
1 parent 824ff6e commit a63d9bb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/AichatwebTemplatesTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ public async Task BasicTest()
7171
filePath.EndsWith("aichatweb/aichatweb.csproj.in"))
7272
{
7373
content.ScrubByRegex("<UserSecretsId>(.*)<\\/UserSecretsId>", "<UserSecretsId>secret</UserSecretsId>");
74-
content.ScrubByRegex("\"(\\d*\\.\\d*\\.\\d*)-(dev|ci)\"", "\"$1\"");
74+
75+
// Scrub references to just-built packages and remove the suffix, if it exists.
76+
// This allows the snapshots to remain the same regardless of where the repo is built (e.g., locally, public CI, internal CI).
77+
var pattern = @"(?<=<PackageReference\s+Include=""Microsoft\.Extensions\..*""\s+Version="")(\d+\.\d+\.\d+)(?:-[^""]*)?(?=""\s*/>)";
78+
content.ScrubByRegex(pattern, replacement: "$1");
7579
}
7680

7781
if (filePath.EndsWith("aichatweb/Properties/launchSettings.json"))

0 commit comments

Comments
 (0)