Last modified: Nov 10, 2024

Update dependencies in app

How to update dependencies in an app.

The app is dependent on multiple external dependencies. This includes larger libraries with common functionality for all apps and reference to the apps frontend.

These dependencies are defined in different places in the app, and each dependency is references by a specific version. When fixes and improvements are made to the dependencies a new version will be published. To use the updated dependencies, you need to update the version use in your app.

Nuget

Nuget is .NET package manager, this is where we publish code libraries that is used by all the apps.

Apps uses multiple libraries, these are updated regularly with improvements and new functionality. Apps references explicit versions of the different libraries. These references must be updated to get the latest version

Upgrade to latest version

Tip Install Version Lens-extension for Visual Studio Code.
With this extension you can view what the latest version of all dependencies when you open App.csproj (the extension also supports npm).

    • Locate the references to the libraries used in your app. The references are located in App/App.csproj.

    Example.:

    <ItemGroup>
      <PackageReference Include="Altinn.App.Api" Version="7.15.1" />
      <PackageReference Include="Altinn.App.Core" Version="7.15.1" />
    </ItemGroup>
    
    • Check if a new version of the libraries are published:
    • Update the reference to the latest version and save the file.
    • Check if there is any breaking changes with the new version, make necessary changes if there are any issues.
    • Build and deploy a new version of your app.
    • Locate the references to the libraries used in your app. The references are located in App/App.csproj.

    Example.:

    <ItemGroup>
      <PackageReference Include="Altinn.App.Api" Version="3.0.0" />
      <PackageReference Include="Altinn.App.Common" Version="3.0.0" />
      <PackageReference Include="Altinn.App.PlatformServices" Version="3.0.0" />
      <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.3" />
      <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
    </ItemGroup>
    

    App frontend

    App frontend is loaded at runtime, through a link to the javascript-file for app frontend. This javascript-file uses Semantic Versioning:

    Given a version number MAJOR.MINOR.PATCH, increment the:

    MAJOR version when you make incompatible API changes,
    MINOR version when you add functionality in a backwards compatible manner, and
    PATCH version when you make backwards compatible bug fixes.

    Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

    The app references by default to a major version of app frontend, e.g. version 1.x.y With the default setup all minor and patch version will be automatically pulled in. If a new major version is published you need to update your app to pull this new version, watch out for breaking changes)

    If you want to lock the frontend to a specific version of app frontend (e.g. 1.2.3) you specify this directly in the URL that points to app frontend.

    Upgrade to new version / specific version

    The reference to app frontend is located in App/views/Home/Index.cshtml.

    You need to update two references:

    • Reference to altinn-app-frontend.js-file which contains the code for app frontend.
    <script src="https://altinncdn.no/toolkits/altinn-app-frontend/<VERSIONNUMBER>/altinn-app-frontend.js"></script>
    
    • Reference to altinn-app-frontend.css which contains the styling for app frontend.
    <script src="https://altinncdn.no/toolkits/altinn-app-frontend/<VERSIONNUMBER>/altinn-app-frontend.css"></script>
    

    Search for the filename (altinn-app-frontend.js or altinn-app-frontend.css) and replace the version number (e.g. 1) with the desired version number (e.g. 2).

    Reminder: If you depend on a major version (e.g. 2), every minor and patch version of this major release will be applied automatically. If a specific version is defined (e.g. 2.0.0) the application will fetch this version until the reference is updated and no fixes or improvements will be fetched.

    Deployment

    Deployments are defined with helm-charts. The standard deployment setup is fetched from altinn-studios helm repository if you leverage the latest deployment strategy (recommended).

    If you unsure if your app leverages the latest deployment strategy you can follow the migration guide here

    To find the latest version of the standard helm-chart you can either check for the latest release of the chart deployment here or add the helm repo locally and search for available version with these commands:

    # Add the altinn-studio helm repo
    helm repo add altinn-studio https://charts.altinn.studio
    
    # Search for version of altinn-studio/deployment chart
    helm search repo -l altinn-studio/deployment
    

    If there is a new version of the helm chart check the changelog to see what’s new in this release.

    To update to the new version update the dependency reference in deployment/Chart.yaml

    apiVersion: v1
    description: A Helm chart for Kubernetes
    name: deployment
    version: 1.1.0
    
    dependencies:
    - name: deployment
      repository: https://charts.altinn.studio/
      version: 2.8.0                                <--- Update this