Skip to content

Commit 8151668

Browse files
github-actions[bot]mattleibowCopilot
authored
[release/11.0.1xx-preview2] Use wildcard versions for template dependencies in preview builds (#34305)
Backport of #34214 to release/11.0.1xx-preview2 /cc @mattleibow Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 22cf45d commit 8151668

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Templates/src/Microsoft.Maui.Templates.csproj

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,29 @@
8181
DestinationFiles="%(TemplateJsonInput.RelativeDir)templatestrings.json"
8282
Condition="'%(TemplateJsonInput.Filename)%(TemplateJsonInput.Extension)' == 'templatestrings.en.json'" />
8383

84+
<!-- When not stabilized (preview builds), strip the build number and replace with a wildcard:
85+
e.g. 11.0.0-preview.2.26103.111 -> 11.0.0-preview.2.*
86+
MSBuild has no built-in API for semver parsing, so we use Regex to strip the trailing build segments. -->
87+
<PropertyGroup Condition="'$(StabilizePackageVersion)' != 'true'">
88+
<_PreviewWildcardPattern>(-[a-zA-Z][a-zA-Z0-9]*\.\d+)\.\d+\.\d+</_PreviewWildcardPattern>
89+
<_TemplateLoggingDebugVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(MicrosoftExtensionsLoggingDebugVersion)', '$(_PreviewWildcardPattern)', '%241.*'))</_TemplateLoggingDebugVersion>
90+
<_TemplateComponentsWebVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(MicrosoftAspNetCoreComponentsWebPackageVersion)', '$(_PreviewWildcardPattern)', '%241.*'))</_TemplateComponentsWebVersion>
91+
<_TemplateComponentsWebAssemblyVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(MicrosoftAspNetCoreComponentsWebAssemblyPackageVersion)', '$(_PreviewWildcardPattern)', '%241.*'))</_TemplateComponentsWebAssemblyVersion>
92+
<_TemplateComponentsWebAssemblyServerVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(MicrosoftAspNetCoreComponentsWebAssemblyServerPackageVersion)', '$(_PreviewWildcardPattern)', '%241.*'))</_TemplateComponentsWebAssemblyServerVersion>
93+
</PropertyGroup>
94+
<PropertyGroup Condition="'$(StabilizePackageVersion)' == 'true'">
95+
<_TemplateLoggingDebugVersion>$(MicrosoftExtensionsLoggingDebugVersion)</_TemplateLoggingDebugVersion>
96+
<_TemplateComponentsWebVersion>$(MicrosoftAspNetCoreComponentsWebPackageVersion)</_TemplateComponentsWebVersion>
97+
<_TemplateComponentsWebAssemblyVersion>$(MicrosoftAspNetCoreComponentsWebAssemblyPackageVersion)</_TemplateComponentsWebAssemblyVersion>
98+
<_TemplateComponentsWebAssemblyServerVersion>$(MicrosoftAspNetCoreComponentsWebAssemblyServerPackageVersion)</_TemplateComponentsWebAssemblyServerVersion>
99+
</PropertyGroup>
100+
84101
<!-- Replace .NET TFM versions -->
85102
<ReplaceFileText
86103
InputFilename="%(TemplateJsonInput.IntermediateLocation)"
87104
OutputFilename="%(TemplateJsonInput.IntermediateLocation)"
88105
MatchExpression="DOTNET_TFM_VALUE;DOTNET_TFM_VERSION_VALUE;DOTNET_TFM_VERSION_MAJOR_VALUE;MS_EXT_LOG_DEBUG_VERSION_VALUE;MS_COMPONENTS_WEB_VERSION_VALUE;MS_COMPONENTS_WEBASSEMBLY_VERSION_VALUE;MS_COMPONENTS_WEBASSEMBLY_SERVER_VERSION_VALUE"
89-
ReplacementText="$(_MauiDotNetTfm);$(_MauiDotNetVersion);$(_MauiDotNetVersionMajor)000;$(MicrosoftExtensionsLoggingDebugVersion);$(MicrosoftAspNetCoreComponentsWebPackageVersion);$(MicrosoftAspNetCoreComponentsWebAssemblyPackageVersion);$(MicrosoftAspNetCoreComponentsWebAssemblyServerPackageVersion)" />
106+
ReplacementText="$(_MauiDotNetTfm);$(_MauiDotNetVersion);$(_MauiDotNetVersionMajor)000;$(_TemplateLoggingDebugVersion);$(_TemplateComponentsWebVersion);$(_TemplateComponentsWebAssemblyVersion);$(_TemplateComponentsWebAssemblyServerVersion)" />
90107

91108
<ItemGroup>
92109
<FileWrites Include="%(TemplateJsonInput.IntermediateLocation)" />

0 commit comments

Comments
 (0)