Setting package version
# package-development
s
Hi all, sorry if this has been asked before (i did a quick naive search but didn't find anything) - regarding the umbraco-package.json file for v14/15 and it's "Version" (https://docs.umbraco.com/umbraco-cms/customizing/umbraco-package#version) parameter - this seems to indicate that it should/must be inline with the version of the Nuget package being distributed. Is there any guidance on how to make that happen or is it a case where we need to have a step in the build pipeline to parse/replace this JSON with the version of the package being built?
n
We do this with a build target in the static assets project file - using JsonPathUpdateValue from Umbraco.JsonSchema.Extensions. A few lines of config, no code to maintain at the expense of a small dependency.
l
@User I was wondering the same! Do you have an example?
I really liked the property "versionAssemblyName" in the original package.manifest file in Umbraco 13
@shazwazza. Ah I figured it out in case you didn't yet Install the Umbraco.JsonSchema.Extensions package (https://github.com/umbraco/Umbraco.JsonSchema.Extensions) and add the following to your project file (adjust where needed ofcourse, I read the VersionPrefix for instance):
Copy code
xml
<Target Name="UpdateUmbracoPackageJsonVersion" AfterTargets="Build">
  <JsonPathUpdateValue
    JsonFile="$(ProjectDir)wwwroot\App_Plugins\Example\umbraco-package.json"
    Path="$.version"
    Value=""$(VersionPrefix)"" />
  <Message Text="Updated umbraco-package.json version to $(VersionPrefix)." Importance="High" />
</Target>
I still need to check if this works on Linux and our build pipelines though
6 Views