microsoft / azuredevopslabs

Learn how you can plan smartly, collaborate better, and ship faster with a set of modern development services with Azure DevOps.
https://www.azuredevopslabs.com
MIT License
806 stars 904 forks source link

CI Build Failing at Publish Task #625

Closed palchak closed 2 years ago

palchak commented 2 years ago

@sriramdasbalaji

I am following the link https://azuredevopslabs.com/labs/vstsextend/terraform/ and running the CI pipeline. This is my below YAML file

trigger:
- master

pool:
  vmimage : windows-latest

variables:
   BuildConfiguration: 'release'
   buildPlatform: 'any cpu'

steps:
- task: DotNetCoreCLI@2
  displayName: Restore  
  inputs:
    command: 'restore'
    projects: '**/*.csproj'

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    arguments: '--configuration $(BuildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: test
    projects: '**/*[Tt]ests/*.csproj'
    arguments: '--configuration $(BuildConfiguration)'

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 2.0.0'
  inputs:
    version: '2.0.0'

- task: DotNetCoreCLI@2
  displayName: Publish
  inputs:
    command: 'publish'
    publishWebProjects: true
    arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'

- task: CopyFiles@2
  displayName: 'Copy Terraform files to artifacts'
  inputs:
    SourceFolder: Terraform
    TargetFolder: '$(build.artifactstagingdirectory)/Terraform'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: 'drop'

The build fails at Publish task with the error :

C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ConflictResolution.targets(112,5): error NETSDK1152: Found multiple publish output files with the same relative path: D:\a\1\s\src\PartsUnlimited.Models\config.json, D:\a\1\s\src\PartsUnlimitedWebsite\config.json. [D:\a\1\s\src\PartsUnlimitedWebsite\PartsUnlimitedWebsite.csproj]

Any idea how to fix this Build

sriramdasbalaji commented 2 years ago

Hi @palchak ,

Update image to

pool:
  vmimage: 'windows-2019'

and add an additional task in steps

steps:
- powershell: 'choco install dotnetcore-sdk --version=2.0.0'
  displayName: 'Install .net core 2.0.0'

This worked for me, I will have this updated in the template. Thanks