skartknet / Iconic

The ultimate icon picker for Umbraco backoffice
MIT License
6 stars 8 forks source link

Can't deploy on Umbraco 8 with Azure DevOps #35

Closed robertjf closed 1 year ago

robertjf commented 1 year ago

I've been investigating why the iconic files haven't been updating properly on some installs we have where we use AzureDevOps CI/CD to do the installation.

Umbraco: 8.18.17 Our.Iconic: latest (upgraded from Koben.Iconic).

We discovered this issue while attempting to upgrade from Koben.Iconic, and found that the package manifest on the server still referenced Koben.Iconic after a push.

What I've found happening is this (from the CI/CD logs):

  1. It removes any pre-existing files from App_Plugins/Iconic:
    2023-05-24T06:50:24.8046769Z ClearIconicAssets:
    2023-05-24T06:50:24.8047176Z   Clear old Iconic plguin files [Typo in targets file]
    2023-05-24T06:50:24.8149333Z   Directory "D:\a\1\s\src\<PROJECT_NAME>\App_Plugins\Iconic\" doesn't exist. Skipping.
  2. It then restores nuget files, and adds all available files to the package for deployment.
  3. After that, it copies the App_Plugins/Iconic files from the nuget package to the App_Plugins folder in the website - however, by now it's too late, as it's already built the package for deployment.

The project file is configured to not include the app_plugins\Iconic directory - if it does, then the CI/CD fails when attempting to publish the files as they are deleted by step 1 above.

An example of the CI/CD yaml:

# Umbraco 8 Build Pipeline

trigger:
- schema

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**\*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1
  inputs:
    versionSpec: 

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '$(solution)'
    feedsToUse: 'select'

# Build fails on this task due to trying to publish if the files are included in the project.
- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    msbuildArgs: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
    clean: true
    msbuildArchitecture: 'x64'
    createLogFile: true

- task: PublishPipelineArtifact@1
  inputs:
    targetPath: '$(Pipeline.Workspace)'
    artifact: '_artifact'
    publishLocation: 'pipeline'
robertjf commented 1 year ago

It's worth noting that ConditionalDisplayers also suffers from the same problem.

skartknet commented 1 year ago

Hey @robertjf , just a note that it looks weird that both packages have the same problem. Iconic is a Razor Class but CD is not. 🤷

Also, I'm not sure if the lastest version of Iconic is meant to work on v8...

Given that the latest version of Iconic is a RCL, there shouldn't be any folder in App_Plugins. All is contained in the Iconic DLL

Remove all the old iconic files, including any target files that you had.

Umbraco V8 targets .NET 4.7 but the latest Iconic targets net6 and 7.

robertjf commented 1 year ago

Hey @skartknet apologies - we're using Our.Iconic 4.0.0 and Our.Iconic.Core 3.2.0.

We've arrived at a solution with the CI/CD build that gets around the issue - split the VSBuild@1 task into two steps - one to clean and build, the other to publish:

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    msbuildArgs:
    clean: true
    msbuildArchitecture: 'x64'
    createLogFile: true

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    msbuildArgs: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
    clean: false
    msbuildArchitecture: 'x64'
    createLogFile: true

We also discovered that the latest ConditionalDisplayers does not work on Umbraco 8 due to the use of uUI - I'll add an issue on the appropriate repository for you.