【发布时间】:2020-02-12 23:25:11
【问题描述】:
在answer to this question 中,我需要将构建 yaml 从使用 Nuget 更改为使用 DotNet 这样 .net 标准项目才能正确打包(我希望)。然而,当我这样做时,我开始得到 p>
错误 MSB4057:项目中不存在目标“pack”
对于框架项目。
我应该分离存储库还是有办法为不同的目标指定不同的打包命令?
我原来的 azure-pipelines.yml 是
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
Major: '2'
Minor: '0'
Patch: '0'
steps:
- task: NuGetToolInstaller@0
inputs:
versionSpec: '>=4.3.0'
checkLatest: true
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: NuGetCommand@2
inputs:
command: pack
packagesToPack: '**/*.csproj'
versioningScheme: byPrereleaseNumber
majorVersion: '$(Major)'
minorVersion: '$(Minor)'
patchVersion: '$(Patch)'
- task: NuGetCommand@2
inputs:
command: pack
packagesToPack: '**/*.vbproj'
versioningScheme: byPrereleaseNumber
majorVersion: '$(Major)'
minorVersion: '$(Minor)'
patchVersion: '$(Patch)'
- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: push
publishVstsFeed: 'SBDCommonFeed'
allowPackageConflicts: true
但我将 NuGetCommand@2 任务更改为
- task: DotNetCoreCLI@2
inputs:
command: 'pack'
outputDir: '$(Build.ArtifactStagingDirectory)/TestDir'
对于 Nuget 命令,我可以尝试使用 PackagesToPack 我要为 DotNet 命令更改什么?
[更新] 我试过了
- task: DotNetCoreCLI@2
inputs:
command: 'pack'
projects: '**/*Standard.csproj'
outputDir: '$(Build.ArtifactStagingDirectory)/OutputDir'
其中 *Standard 是 .net 标准项目。但是框架项目中仍然存在 MSB4057 错误
【问题讨论】:
-
你也可以用
packagesToPack:代替Projects:做dotnet pack。由于我们只需要打包 .net 标准项目,您可以传递类似:packagesToPack: '**/LibraryProjectName.csproj' -
就是这样。谢谢。
-
如果新创建的包可以在您的项目中很好地使用,请随时告诉我。 (并且您可能需要clean the nuget cache 以避免旧缓存影响 nuget 行为。)
标签: azure-devops azure-pipelines