From 843d0c601349649267777e018c838ecce4d0454d Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 24 Feb 2026 18:24:24 +0200 Subject: [PATCH] Use wildcard versions for template dependencies in preview builds When StabilizePackageVersion is false, strip the build number from external dependency versions used in templates and replace with a wildcard. For example, 11.0.0-preview.2.26103.111 becomes 11.0.0-preview.2.* so template-generated projects don't pin to a specific build number during preview. Affects: MS_EXT_LOG_DEBUG_VERSION_VALUE, MS_COMPONENTS_WEB_VERSION_VALUE, MS_COMPONENTS_WEBASSEMBLY_VERSION_VALUE, MS_COMPONENTS_WEBASSEMBLY_SERVER_VERSION_VALUE Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../src/Microsoft.Maui.Templates.csproj | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Templates/src/Microsoft.Maui.Templates.csproj b/src/Templates/src/Microsoft.Maui.Templates.csproj index d69a81e135b7..9e3aec06a9d0 100644 --- a/src/Templates/src/Microsoft.Maui.Templates.csproj +++ b/src/Templates/src/Microsoft.Maui.Templates.csproj @@ -81,12 +81,29 @@ DestinationFiles="%(TemplateJsonInput.RelativeDir)templatestrings.json" Condition="'%(TemplateJsonInput.Filename)%(TemplateJsonInput.Extension)' == 'templatestrings.en.json'" /> + + + <_PreviewWildcardPattern>(-[a-zA-Z][a-zA-Z0-9]*\.\d+)\.\d+\.\d+ + <_TemplateLoggingDebugVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(MicrosoftExtensionsLoggingDebugVersion)', '$(_PreviewWildcardPattern)', '%241.*')) + <_TemplateComponentsWebVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(MicrosoftAspNetCoreComponentsWebPackageVersion)', '$(_PreviewWildcardPattern)', '%241.*')) + <_TemplateComponentsWebAssemblyVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(MicrosoftAspNetCoreComponentsWebAssemblyPackageVersion)', '$(_PreviewWildcardPattern)', '%241.*')) + <_TemplateComponentsWebAssemblyServerVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(MicrosoftAspNetCoreComponentsWebAssemblyServerPackageVersion)', '$(_PreviewWildcardPattern)', '%241.*')) + + + <_TemplateLoggingDebugVersion>$(MicrosoftExtensionsLoggingDebugVersion) + <_TemplateComponentsWebVersion>$(MicrosoftAspNetCoreComponentsWebPackageVersion) + <_TemplateComponentsWebAssemblyVersion>$(MicrosoftAspNetCoreComponentsWebAssemblyPackageVersion) + <_TemplateComponentsWebAssemblyServerVersion>$(MicrosoftAspNetCoreComponentsWebAssemblyServerPackageVersion) + + + ReplacementText="$(_MauiDotNetTfm);$(_MauiDotNetVersion);$(_MauiDotNetVersionMajor)000;$(_TemplateLoggingDebugVersion);$(_TemplateComponentsWebVersion);$(_TemplateComponentsWebAssemblyVersion);$(_TemplateComponentsWebAssemblyServerVersion)" />