Reputation: 18170
In the answer to this question I needed to change the build yaml from using Nuget to using DotNet So that the .net standard project would pack correctly ( i hope ). However when I did this I started getting
error MSB4057: The target "pack" does not exist in the project
for the framework projects.
Should I be separating the repositories or is there some way to specify different pack commands for different targets?
My original azure-pipelines.yml was
# .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://learn.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
but I changed the NuGetCommand@2 task to be
- task: DotNetCoreCLI@2
inputs:
command: 'pack'
outputDir: '$(Build.ArtifactStagingDirectory)/TestDir'
For the Nuget command I can experiment with PackagesToPack What do I change for the DotNet command?
[Update] I tried
- task: DotNetCoreCLI@2
inputs:
command: 'pack'
projects: '**/*Standard.csproj'
outputDir: '$(Build.ArtifactStagingDirectory)/OutputDir'
Where *Standard are the .net standard projects. However there was still the MSB4057 error on a framework project
Upvotes: 0
Views: 1867
Reputation: 28196
The error indicates you're trying to pack both the .net standard
project and .net framework
project while you only need to pack the .net standard library project. (Also, dotnet pack should not be used to pack one non-library project.)
So the workaround is to specify the project to pack when using dotnet pack task. The Pack
command in .net core task also supports packagesToPack
element.
See #packagesToPack: '**/*.csproj' # Required when command == Pack
.
Normally the format is:
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet pack'
inputs:
command: pack
packagesToPack: '**/ProjectName.csproj'
configuration: Release
versioningScheme: xxx
minorVersion: xxx
buildProperties: xxx
...
Upvotes: 1