我有一个用 C# 编写的 2 个类库的解决方案。
我在 Azure DevOps 中有一个管道,用于构建和发布一个 NuGet 包,并且它正在运行。 YAML 是
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: DotNetCoreCLI@2
displayName: Restore packages
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: 'select'
- task: DotNetCoreCLI@2
displayName: Build project
inputs:
command: 'build'
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
displayName: Run tests
inputs:
command: 'test'
projects: '**/*[Te]ests/*.csproj'
- task: NuGetCommand@2
displayName: Prepare the package
inputs:
command: 'pack'
packagesToPack: '**/*.csproj'
versioningScheme: 'byEnvVar'
versionEnvVar: 'PackageVersion'
- task: NuGetCommand@2
displayName: Push the package
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'xxx'
当我有 2 个项目时,该管道失败了。我注意到在构建步骤中,项目是在
Debug
文件夹中创建的。
在“准备包”中,管道正在 Azure DevOps 的 Release
文件夹中搜索
.dll。
那么我有几个问题:
因此您应该为构建步骤提供
--configuration Release
。由于您没有提供它,因此它会将“调试”视为默认值,并将“打包”视为默认值。
variables:
buildConfiguration: 'Release'
steps:
- task: DotNetCoreCLI@2
displayName: Restore packages
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: 'select'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
projects: '**/*.csproj'
displayName: 'dotnet build $(buildConfiguration) --no-restore'
- task: DotNetCoreCLI@2
inputs:
command: test
projects: '**/*[Te]ests/*.csproj'
arguments: '--configuration $(buildConfiguration) --no-build'
- task: DotNetCoreCLI@2
displayName: 'dotnet pack'
inputs:
command: 'pack'
projects: '**/*.csproj'
arguments: '-o $(Build.ArtifactStagingDirectory)/Output --no-build'
versioningScheme: 'byEnvVar'
versionEnvVar: 'PackageVersion'
- task: DotNetCoreCLI@2
displayName: "Publish packages"
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/Output/*.*nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'guid'
回答您的其他问题:
是否可以使用同一管道创建和发布多个包?
是的
我正在使用 Visual Studio 2021,但尚未创建任何 .nuspec。我必须创建它们吗?
没有