我遇到了一个问题,感觉应该很简单,但我正在努力寻找解决方案。我有一个包含多个类库的解决方案,这些类库也依赖于同一解决方案中的共享项目引用。此示例是 .NET Framework 4.8.1,但我的管道模板也适用于 .NET。
NuGet Packages:
ClassLibrary1.dll
-> SharedProject.dll
ClassLibrary2.dll
-> SharedProject.dll
...
我当前的管道大部分工作正常,它允许您打包和发布 DLL 的预发布和发布版本。但是,它仅包含“ClassLibrary1.dll”,但不包含“SharedProject.dll”
variables:
PrereleaseVersion: '$(build.buildNumber)-prerelease'
ReleaseVersion: '$(build.buildNumber)'
...
- task: NuGetCommand@2
displayName: 'Pack Prerelease Nuget Package'
inputs:
command: pack
packagesToPack: $(project)
versioningScheme: 'byEnvVar'
versionEnvVar: 'PrereleaseVersion'
关闭 versioningScheme 并添加 includeReferencedProjects,它会正确打包 ClassLibrary1.dll 和 SharedProject.dll,但是(从我通过阅读文档和测试可以看出)只是默认为“ClassLibrary1.Major.Minor.Build”无法添加 -prerelease 的程序集。任何帮助将不胜感激,谢谢。
- task: NuGetCommand@2
displayName: 'Pack Prerelease Nuget Package'
inputs:
command: pack
packagesToPack: $(project)
versioningScheme: 'off'
includeReferencedProjects: true
尝试使用 MSBuild 任务而不是 NuGetCommand 任务。
例如:
variables:
- name: solution
value: '**/*.sln'
- name: authors
value: 'xxx'
- name: companyName
value: 'xxx'
- name: currentYear
value: $[format('{0:yyyy}', pipeline.startTime)]
- name: copyright
value: 'Copyright © $(currentYear) $(companyName)'
- name: description
value: 'Test.'
steps:
#Create a pipeline variable called "packageVersion", then use below task to set the version increment
- task: version-increment-task@0
inputs:
incrementType: patch
versionVariable: packageVersion
#condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/master'))
displayName: Generate version number
- task: Assembly-Info-NetCore@3
inputs:
Path: '$(Build.SourcesDirectory)/YourProject'
FileNames: '**/*.csproj'
InsertAttributes: true
FileEncoding: 'auto'
WriteBOM: false
PackageId: 'XXXX'
Authors: '$(authors)'
Company: '$(companyName)'
Product: 'CW.WPF.Material'
Description: '$(description)'
Copyright: '$(copyright)'
PackageProjectUrl: 'https://XXXX'
RepositoryUrl: 'https://dev.azure.com/XXXX'
RepositoryType: 'git'
PackageTags: 'XXXX'
VersionNumber: '$(packageVersion)'
InformationalVersion: '$(packageVersion)'
PackageVersion: '$(packageVersion)'
LogLevel: 'verbose'
FailOnWarning: true
DisableTelemetry: true
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
- task: MSBuild@1
inputs:
solution: '$(solution)'
configuration: 'Release'
#build and pack the package, then publish the package to azure feed.
- task: MSBuild@1
inputs:
solution: '$(solution)'
msbuildArguments: '-t:Pack -p:Configuration="Release" -p:IncludeSource=true -p:IncludeSymbols=true -p:PackageOutputPath=$(Build.artifactstagingdirectory) -p:Authors="$(authors)" -p:Copyright="$(copyright)" -p:PackageVersion=$(packageVersion)-prerelease -p:Description="$(description)"'
- task: NuGetCommand@2
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'your feed'