Search code examples
azure-devopsyaml

YAML CI is flattening file structure


I'm hosting my repo in GitHub and using Azure DevOps for the CI/CD pipelines. I've done this before using the GUI CI/CD screens with no problem.

The first thing that I've noticed is that the build process using YAML seems to flatten the file structure. I'm also seeing some XML and TXT files instead of the actual JSON files in the drop folder.

So, in the drop folder instead of seeing drop/AzureResourceGroup/azuredeploy.parameters-dev.json I see drop/TestYAML.Parameters.xml

Build and Publish tasks:

stages:
- stage: Build
  jobs: 
  - job: Build

    pool:
      vmImage: 'windows-2019'

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

    steps:
    - task: NuGetToolInstaller@1
    - task: NuGetCommand@2
      inputs:
        restoreSolution: '$(solution)'      
    - task: VSBuild@1
      inputs: 
        solution: '$(solution)'
        msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\" /p:SourceLinkCreate=true'
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
    - task: PublishBuildArtifacts@1
      inputs: 
        pathToPublish: '$(Build.ArtifactStagingDirectory)' 
        artifactName: 'drop' 
        publishLocation: 'container' # Options: container, filePath
        #targetPath: # Required when publishLocation == FilePath
        #parallel: false # Optional
        #parallelCount: # Optional
        #fileCopyOptions: #Optional

Edited to show package contents.

After I download and unzip the file, this is what I see. The files from two different projects are shoved under the same folder: enter image description here

Files immediately available in the artifact: enter image description here

VS Build Log:


Solution

  • The main issue I had was that the azuredeploy JSON files weren't in the drop folder after the build task to be used by the deployment task(s). I would up having to use the Copy Files task to be able to get the files there.

    - task: CopyFiles@2
          displayName: 'Copy Files to: $(build.ArtifactStagingDirectory)/AzureResourceGroup'
          inputs:
            SourceFolder: TestYAML\AzureResourceGroup
            Contents: '*.json'
            TargetFolder: '$(build.ArtifactStagingDirectory)/AzureResourceGroup'
    

    While this works, I don't understand why Microsoft breaks away from automatically including these files. I don't know if the difference is YAML or .NET Core vs .NET Framework, but the build pipelines I set up using the GUI on other projects that have azuredeploy JSON files include this step as part of the Build task.