【发布时间】:2019-12-04 08:03:36
【问题描述】:
- job: buildAndTestJob
steps:
- task: DotNetCoreCLI@2
displayName: dotnet restore
inputs:
command: restore
vstsFeed: $(vstsFeed)
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
arguments: '--configuration ${{ parameters.buildConfiguration }}'
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: test
arguments: '--configuration ${{ parameters.buildConfiguration }}'
- task: CopyFiles@2
displayName: copy bin files
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: '**/bin/**/*'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: CopyFiles@2
displayName: copy obj files
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: '**/obj/**/*'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
displayName: publish build artifacts
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: buildeffect
publishLocation: 'Container'
-job: packAndPushJob
steps:
- task: DownloadBuildArtifacts@0
displayName: download build artifacts
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'buildeffect'
downloadPath: '$(Build.ArtifactStagingDirectory)'
- task: CopyFiles@2
displayName: copy files to source directory
inputs:
sourceFolder: '$(Build.ArtifactStagingDirectory)/buildeffect'
contents: '**/*'
TargetFolder: '$(Build.SourcesDirectory)'
allowPackageConflicts: true
- task: DotNetCoreCLI@2
displayName: 'dotnet pack'
inputs:
arguments: '--no-restore'
nobuild: true
command: pack
projects: '$(Build.SourcesDirectory)'
publishWebProjects: true
publishVstsFeed: $(vstsFeed)
includeNuGetOrg: true
- task: NuGetCommand@2
displayName: 'nuGet push'
inputs:
command: push
projects: '$(Build.SourcesDirectory)'
publishVstsFeed: $(vstsFeed)
allowPackageConflicts: true
我有 2 份工作。首先,在构建工件中恢复、测试、构建和共享构建文件。其次是打包和推送nuget包。第一份工作成功完成了他们的工作,但第二份工作在打包任务中失败了。 nuget包有问题,例如:
/usr/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1064: Package Microsoft.CSharp, version 4.6.0 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. [/home/vsts/work/1/s/src/Spotio.Leads.Client/Spotio.Leads.Client.csproj]
那么,也许我们应该以另一种方式共享已构建的项目?或者也许可以添加一些带有提要的参数来恢复?我没有任何想法,所以请,如果您有任何建议,请帮助我们:)
【问题讨论】:
-
您在发布之前尝试过 azure 管道的“nuget 命令”吗?并确保清除恢复 nuGet 包复选框
-
您的意思是在第一份工作中发布工件之前放置 nuget 包吗?是的,它有效,但我们需要分开工作
-
@SebastianSarnecki 尝试在包参数中添加
--no-build。 -
@ShaykiAbramczyk 添加后 --no-build 仍然是相同的结果
-
使用
dotnet pack命令时,dotnet cli 将尝试确认引用的包是否存在,尽管项目已经构建并且程序集已经输出。我假设您使用的是托管代理,为此,您需要在第二个代理作业中使用 dotnet pack 命令之前恢复包...
标签: c# .net-core azure-devops azure-pipelines .net-core-3.0