Search code examples
c#azure-devops.net-core-3.0

dotnet\sdk\3.0.100\NuGet.targets(123,5): error : Ambiguous project name


I'm currently trying to build an api and an azure webjob as a selfcontained .net core 3.0 app but during the build process i'm getting the following error no matter what configuration I try.

C:\hostedtoolcache\windows\dotnet\sdk\3.0.100\NuGet.targets(123,5): error : Ambiguous project name 'Grey-O-Tron'. [D:\a\1\s\Grey-O-Tron.sln]

This is the current build setup

pool:
  name: Azure Pipelines
variables:
  build.gittag: '6.6.1'
  build.number: '17'
  build.gitversion: '6.6.1+17'

steps:
- task: NuGetToolInstaller@1
  displayName: 'Use NuGet 5.3.0'
  inputs:
    versionSpec: 5.3.0

- task: UseDotNet@2
  displayName: 'Use .Net Core sdk 3.x'
  inputs:
    version: 3.x
    includePreviewVersions: true

- task: WouterVS.set-git-version-task.custom-build-release-task.Set git version@1
  displayName: 'Set Build''s Git Version'

- task: NuGetCommand@2
  displayName: 'NuGet restore'

- task: bleddynrichards.Assembly-Info-Task.Assembly-Info-NetCore.Assembly-Info-NetCore@2
  displayName: 'Set Assembly Manifest Data'
  inputs:
    InsertAttributes: true
    FileEncoding: 'utf-8'
    PackageId: 'Grey-O-Tron'
    Authors: 'Wouter Van Speybroeck'
    Company: woutervs
    Product: 'Grey-O-Tron'
    Copyright: 'Wouter Van Speybroeck'
    PackageProjectUrl: greyotron.eu
    RepositoryUrl: 'https://github.com/woutervs/Grey-O-Tron'
    VersionNumber: '$(build.gittag).$(build.number)'
    FileVersionNumber: '$(build.gittag).$(build.number)'
    InformationalVersion: '$(build.gitversion)'
    PackageVersion: '$(build.gitversion)'

- task: VSBuild@1
  displayName: 'Build solution **\*.sln'
  inputs:
    platform: x86
    configuration: release
  enabled: false

- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    arguments: '-c release -r win-x86'

- task: DotNetCoreCLI@2
  displayName: 'publish api'
  inputs:
    command: publish
    publishWebProjects: false
    projects: '**/*Api.csproj'
    arguments: '--no-build -o $(build.artifactstagingdirectory) -c release -r win-x86 --self-contained true'
    zipAfterPublish: false
    modifyOutputPath: false

- task: DotNetCoreCLI@2
  displayName: 'publish bot'
  inputs:
    command: publish
    publishWebProjects: false
    projects: '**/Grey-O-Tron.csproj'
    arguments: '--no-build -o $(build.artifactstagingdirectory)\app_data\Jobs\Continuous\Grey-O-Tron -c release -r win-x86 --self-contained true'
    zipAfterPublish: false
    modifyOutputPath: false

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'

pool:
  name: Azure Pipelines
variables:
  build.gittag: '6.6.1'
  build.number: '17'
  build.gitversion: '6.6.1+17'

steps:
- task: NuGetToolInstaller@1
  displayName: 'Use NuGet 5.3.0'
  inputs:
    versionSpec: 5.3.0

- task: UseDotNet@2
  displayName: 'Use .Net Core sdk 3.x'
  inputs:
    version: 3.x
    includePreviewVersions: true

- task: WouterVS.set-git-version-task.custom-build-release-task.Set git version@1
  displayName: 'Set Build''s Git Version'

- task: NuGetCommand@2
  displayName: 'NuGet restore'

- task: bleddynrichards.Assembly-Info-Task.Assembly-Info-NetCore.Assembly-Info-NetCore@2
  displayName: 'Set Assembly Manifest Data'
  inputs:
    InsertAttributes: true
    FileEncoding: 'utf-8'
    PackageId: 'Grey-O-Tron'
    Authors: 'Wouter Van Speybroeck'
    Company: woutervs
    Product: 'Grey-O-Tron'
    Copyright: 'Wouter Van Speybroeck'
    PackageProjectUrl: greyotron.eu
    RepositoryUrl: 'https://github.com/woutervs/Grey-O-Tron'
    VersionNumber: '$(build.gittag).$(build.number)'
    FileVersionNumber: '$(build.gittag).$(build.number)'
    InformationalVersion: '$(build.gitversion)'
    PackageVersion: '$(build.gitversion)'

- task: VSBuild@1
  displayName: 'Build solution **\*.sln'
  inputs:
    platform: x86
    configuration: release
  enabled: false

- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    arguments: '-c release -r win-x86'

- task: DotNetCoreCLI@2
  displayName: 'publish api'
  inputs:
    command: publish
    publishWebProjects: false
    projects: '**/*Api.csproj'
    arguments: '--no-build -o $(build.artifactstagingdirectory) -c release -r win-x86 --self-contained true'
    zipAfterPublish: false
    modifyOutputPath: false

- task: DotNetCoreCLI@2
  displayName: 'publish bot'
  inputs:
    command: publish
    publishWebProjects: false
    projects: '**/Grey-O-Tron.csproj'
    arguments: '--no-build -o $(build.artifactstagingdirectory)\app_data\Jobs\Continuous\Grey-O-Tron -c release -r win-x86 --self-contained true'
    zipAfterPublish: false
    modifyOutputPath: false

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'

Repo can be found at: https://github.com/woutervs/Grey-O-Tron


Solution

  • It seems that task Set Assembly Manifest Data sets the project id for your projects to a same value "Grey-O-Tron". Usually project id should be unique or blank for csproj.

    You may need to omit the input PackageId for this task. I tested below yml, the build was successful without PackageId

    - task: bleddynrichards.Assembly-Info-Task.Assembly-Info-NetCore.Assembly-Info-NetCore@2
      displayName: 'Set Assembly Manifest Data'
      inputs:
        InsertAttributes: true
        FileEncoding: 'utf-8'
    
        Authors: 'Wouter Van Speybroeck'
        Company: woutervs
        Product: 'Grey-O-Tron'
        Copyright: 'Wouter Van Speybroeck'
        PackageProjectUrl: greyotron.eu
        RepositoryUrl: 'https://github.com/woutervs/Grey-O-Tron'
        VersionNumber: '$(build.gittag).$(build.number)'
        FileVersionNumber: '$(build.gittag).$(build.number)'
        InformationalVersion: '$(build.gitversion)'
        PackageVersion: '$(build.gitversion)'