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:
@@ -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}
|
||||
|
||||
@@ -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=""$(PackageVersion)"" />
|
||||
<ItemGroup>
|
||||
<_PackageFiles Remove="@(_TemplateJsonFiles)" />
|
||||
<_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)">
|
||||
<PackagePath>%(RelativeDir)</PackagePath>
|
||||
</_PackageFiles>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user