Update default UmbracoVersion template value using MSBuild target (#13481)

* Update default UmbracoVersion template value using MSBuild target

* Fix target order when using pack --no-build

* Use JsonPathUpdateValue MSBuild task to update default UmbracoVersion template value

* Update UmbracoVersion in Umbraco Package RCL
This commit is contained in:
Ronald Barendse
2023-04-05 11:16:43 +02:00
committed by GitHub
parent 92d92feb15
commit 4cb46f06ae
5 changed files with 27 additions and 20 deletions

View File

@@ -94,23 +94,8 @@ stages:
echo "##vso[task.setvariable variable=majorVersion;isOutput=true]$major"
displayName: Set major version
name: determineMajorVersion
- task: PowerShell@2
displayName: Prepare nupkg
inputs:
targetType: inline
script: |
$umbracoVersion = "$(Build.BuildNumber)" -replace "\+",".g"
$templatePaths = Get-ChildItem 'templates/**/.template.config/template.json'
foreach ($templatePath in $templatePaths) {
$a = Get-Content $templatePath -Raw | ConvertFrom-Json
if ($a.symbols -and $a.symbols.UmbracoVersion) {
$a.symbols.UmbracoVersion.defaultValue = $umbracoVersion
$a | ConvertTo-Json -Depth 32 | Set-Content $templatePath
}
}
dotnet pack $(solution) --configuration $(buildConfiguration) --no-build --property:PackageOutputPath=$(Build.ArtifactStagingDirectory)/nupkg
- script: dotnet pack $(solution) --configuration $(buildConfiguration) --no-build --property:PackageOutputPath=$(Build.ArtifactStagingDirectory)/nupkg
displayName: Run dotnet pack
- script: |
sha="$(Build.SourceVersion)"
sha=${sha:0:7}

View File

@@ -8,6 +8,7 @@
<NoDefaultExcludes>true</NoDefaultExcludes>
<IncludeContentInPack>true</IncludeContentInPack>
<ContentTargetFolders>.</ContentTargetFolders>
<NoWarn>NU5128</NoWarn>
</PropertyGroup>
<ItemGroup>
@@ -43,4 +44,25 @@
<PackagePath>UmbracoProject\wwwroot</PackagePath>
</Content>
</ItemGroup>
<!-- Update template.json files with the default UmbracoVersion value set to the current build version -->
<ItemGroup>
<PackageReference Include="Umbraco.JsonSchema.Extensions" Version="0.3.0" PrivateAssets="all" />
</ItemGroup>
<Target Name="GetUpdatedTemplateJsonPackageFiles" BeforeTargets="GenerateNuspec" AfterTargets="GetBuildVersion;GetUmbracoBuildVersion">
<ItemGroup>
<_TemplateJsonFiles Include="**\.template.config\template.json" Exclude="bin\**;obj\**" />
<_TemplateJsonFiles>
<DestinationFile>$(IntermediateOutputPath)%(RelativeDir)%(Filename)%(Extension)</DestinationFile>
</_TemplateJsonFiles>
</ItemGroup>
<Copy SourceFiles="@(_TemplateJsonFiles)" DestinationFiles="%(DestinationFile)" />
<JsonPathUpdateValue JsonFile="%(_TemplateJsonFiles.DestinationFile)" Path="$.symbols.UmbracoVersion.defaultValue" Value="&quot;$(PackageVersion)&quot;" />
<ItemGroup>
<_PackageFiles Remove="@(_TemplateJsonFiles)" />
<_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)">
<PackagePath>%(RelativeDir)</PackagePath>
</_PackageFiles>
</ItemGroup>
</Target>
</Project>

View File

@@ -41,7 +41,7 @@
"description": "The version of Umbraco.Cms to add as PackageReference.",
"type": "parameter",
"datatype": "string",
"defaultValue": "11.0.0",
"defaultValue": "*",
"replaces": "UMBRACO_VERSION_FROM_TEMPLATE"
},
"SkipRestore": {

View File

@@ -42,7 +42,7 @@
"description": "The version of Umbraco.Cms to add as PackageReference.",
"type": "parameter",
"datatype": "string",
"defaultValue": "11.0.0",
"defaultValue": "*",
"replaces": "UMBRACO_VERSION_FROM_TEMPLATE"
},
"SkipRestore": {

View File

@@ -51,7 +51,7 @@
"description": "The version of Umbraco.Cms to add as PackageReference.",
"type": "parameter",
"datatype": "string",
"defaultValue": "11.0.0",
"defaultValue": "*",
"replaces": "UMBRACO_VERSION_FROM_TEMPLATE"
},
"UseHttpsRedirect": {