this is my pipeline:
pool:
vmImage: windows-latest
steps:
- task: NuGetToolInstaller#1
displayName: 'Install NuGet >=6.3.0-0'
inputs:
versionSpec: '>=6.3.0-0'
checkLatest: true
- task: UseDotNet#2
displayName: Use DotNet Version 7.0.x
inputs:
version: '7.0.x'
includePreviewVersions: true # Required for preview versions
- task: NuGetCommand#2
displayName: 'Nuget Restore Packages'
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
vstsFeed: '11b33a23-a7bd-4e05-bce5-7383e054c4f4/3aef100d-2005-4893-9c82-65ed96a2b539'
- task: DotNetCoreCLI#2
displayName: 'Build Web API projects'
inputs:
command: build
projects: '**/*src/*.csproj'
arguments: '--configuration $(buildConfiguration)' # Update this to match your need
- task: DotNetCoreCLI#2
displayName: 'Build Database Migrator'
inputs:
command: 'publish'
publishWebProjects: false
projects: '**/*tools/*DatabaseMigrator.csproj'
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/App_Data/jobs/triggered -r win-x64 --self-contained false'
- task: DotNetCoreCLI#2
displayName: 'Build Frequently Operations'
inputs:
command: 'publish'
publishWebProjects: false
projects: '**/*tools/*FrequentlyOperations.csproj'
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/App_Data/jobs/continuous -r win-x64 --self-contained false'
- task: DotNetCoreCLI#2
displayName: 'Create Zip Build For Release'
inputs:
command: publish
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: true
# this code takes all the files in $(Build.ArtifactStagingDirectory) and uploads them as an artifact of your build.
- task: PublishPipelineArtifact#1
displayName: 'Publish Artifact(Zip File) For Release'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: 'output'
when it is triggered it shows this error:
Starting: Build Web API projects
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.210.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
C:\Windows\system32\chcp.com 65001
Active code page: 65001
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[error]Project file(s) matching the specified pattern were not found.
Finishing: Build Web API projects
this is my project:
Any suggestions ?
##[error]Project file(s) matching the specified pattern were not found.
Reproduce the same issue when the csproj file is not in the root node of the src folder.
For example:
-- src
--projectname
-- xxx.csproj
-- projectname1
Usually the src folder will contain multiple project folders.
To solve this issue, you need to check the src folder structure and define the folder path of the dotnet task.
For example:
- task: DotNetCoreCLI#2
displayName: 'Build Web API projects'
inputs:
command: build
projects: '**/*src/** or subfolder name/*.csproj'
arguments: '--configuration $(buildConfiguration)'
From the screenshot of your repo, I didn't see a csproj in your project.
You need to have a csproj in your project.
You could also use sln to restore and build your project.
steps:
- task: UseDotNet#2
displayName: 'Install .NET Core SDK'
inputs:
version: 5.0.x
performMultiLevelLookup: true
includePreviewVersions: true # Required for preview versions
- task: DotNetCoreCLI#2
inputs:
command: 'restore'
projects: '**/*.sln'
displayName: 'Restore Nuget Packages'
- task: DotNetCoreCLI#2
inputs:
command: 'build'
projects: '**/*.sln'
arguments: '--no-restore'
displayName: 'Build projects'
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: true
arguments: '--configuration $(buildConfiguration) --output $(build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: 'api.chibebinam'
Related
For a project I'm using .NET restore for restoring the packages for the projects.
After that I'm publishing my project and running the unit tests. My YAML looks the following (simplified, only the steps below):
steps:
- task: UseDotNet#2
inputs:
version: $(dotNetVersion)
includePreviewVersions: false
- task: DotNetCoreCLI#2
inputs:
command: 'restore'
projects: '**/*.csproj'
restoreArguments: '-r win-x64'
feedsToUse: 'config'
nugetConfigPath: '$(Build.SourcesDirectory)/NuGet.config'
restoreDirectory: '$(Pipeline.Workspace)/packages'
verbosityRestore: 'Quiet'
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: false
projects: '**/PrintTool.csproj'
arguments: '-r win-x64 -p:PublishSingleFile=true --self-contained true --output $(Build.ArtifactStagingDirectory) --no-restore --source $(Pipeline.Workspace)/packages'
zipAfterPublish: false
modifyOutputPath: false
- task: DotNetCoreCLI#2
inputs:
command: 'test'
projects: '**/*Tests.csproj'
arguments: '--no-restore --source $(Pipeline.Workspace)/packages --runtime win-x64'
I've chosen to restore the packages to a specific directory so in a later stage I can use pipeline caching in combination with a lock file.
In the publish step I can refer to the folder in which my NuGet packages are restored. This works with either the parameters --source and --packages.
In the test step I can't find a way to refer to the folder in which my NuGet packages are restored --source and --packages will give the error as a unknown switch. Which I would prefer.
Refer to this doc about Dotnet Test Command.
It doesn't support the argument: --source. So it will show the error: unknown switch.
Example:
You can add additional Dotnet Build Step and add the argument:--no-build to Dotnet Test Task. Then it will directly run the test based on the dll files generated by Dotnet Build Step.
For example:
steps:
- task: UseDotNet#2
inputs:
version: $(dotNetVersion)
includePreviewVersions: false
- task: DotNetCoreCLI#2
inputs:
command: 'restore'
projects: '**/*.csproj'
restoreArguments: '-r win-x64'
feedsToUse: 'config'
nugetConfigPath: '$(Build.SourcesDirectory)/NuGet.config'
restoreDirectory: '$(Pipeline.Workspace)/packages'
verbosityRestore: 'Quiet'
- task: DotNetCoreCLI#2
displayName: Build
inputs:
projects: '$(Parameters.RestoreBuildProjects)'
arguments: '--configuration $(BuildConfiguration) --source $(Pipeline.Workspace)/packages --no-restore'
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: false
projects: '**/PrintTool.csproj'
arguments: '-r win-x64 -p:PublishSingleFile=true --self-contained true --output $(Build.ArtifactStagingDirectory) --no-restore --source $(Pipeline.Workspace)/packages'
zipAfterPublish: false
modifyOutputPath: false
- task: DotNetCoreCLI#2
inputs:
command: 'test'
projects: '**/*Tests.csproj'
arguments: '--no-restore --no-build --runtime win-x64'
My code for the azure pipeline
I have Problems using the azure pipeline, which will automatically pack my libraries on azure devops git and push it as a nugetpackage to artifacts.
I get the error ##[error]No packages matched the search pattern.
at dotnet push
Until that step everything works. I want to pack it as a nuget so i can use it in other projects.
Its a API Client i wrote for my own API.
Try using the artifact path from artifact staging directory
- task: DotNetCoreCLI#2
displayName: 'dotnet build'
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
projects: '**/*.csproj'
- task: DotNetCoreCLI#2
displayName: "dotnet pack"
inputs:
command: 'pack'
arguments: '--configuration $(buildConfiguration)'
packagesToPack: '**/*.csproj'
nobuild: true
versioningScheme: 'off'
- task: NuGetCommand#2
displayName: 'nuget push'
inputs:
command: 'push'
feedsToUse: 'select'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '<Name of Your Feed>'
versioningScheme: 'off'
allowPackageConflicts: true
https://medium.com/#gstvribs/how-to-use-and-deploy-azure-devops-artifacts-on-azure-pipelines-with-dotnet-dockerized-8cebd724f752
Please add to dotnet pack for instance setting like this to your inputs:
packDirectory: "$(Build.ArtifactStagingDirectory)/packages"
And then to dotnet push setting like this:
packagesToPush: '$(Build.ArtifactStagingDirectory)/packages/*.*nupkg'
In your approach it simply try to find packages in defualt folder but you didn't put packages there.
Still trying to get a full grasp on the Azure Pipelines and what I can do with those...
I've managed to finally get my little .NET Core command line utility built with Azure Pipelines - now trying to publish it as a build artifact.
With this YAML, I can build and package the tool:
- task: DotNetCoreCLI#2
displayName: 'dotnet build'
inputs:
command: 'build'
projects: '$(solution)'
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
command: publish
publishWebProjects: False
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
- task: PublishBuildArtifacts#1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'MyTool_LatestBuild'
But in the published build artifacts, I only get a file a.zip - is there any way I can influence the name of that ZIP archive?? I'd really love to have something like MyTool_2020_Sep_08.zip or MyTool_v1.5.7.zip something.... but how can I do that?? Can't seem to find anything very useful anywhere on the interwebs ... any inputs?
Thanks!
1.Agree with Vernou. You can customize the name by specifying the folder name that contains your binaries. So we need to modify the --output argument of dotnet publish step and PathtoPublish argument of PublishBuildArtifacts step.
2.But to get Date time, you can use Build.BuildNumber which is predefined variables.
My working sample:
name: $(Date:yyyyMMdd)$(Rev:.r)
steps:
- task: DotNetCoreCLI#2
inputs:
command: 'build'
projects: '**/*.csproj'
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
command: publish
publishWebProjects: False
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/MyTool_$(Build.BuildNumber)'
zipAfterPublish: True
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/MyTool_$(Build.BuildNumber)'
ArtifactName: 'MyTool_LatestBuild'
publishLocation: 'Container'
More details about using BuildNumber to get date, you can check Configure run or build numbers.
The result:
We can control the format via modifying how we define the Build.BuildNumber(In Yaml, it's name). If we define name: $(Date:yyyyMMdd), then the output zip would be MyTool_20200908.zip.
EDIT: Loking at vernou's answer - i was wrong, i'll leave this here because some may prefer to have different steps and we all love copying from SO.
The Task you're using does not contain that power, but you can (like i have) opt to zip it yourself instead:
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: false
projects: |
**/*Client.csproj
**/*WorkerService.csproj
**/*Server.csproj
arguments: '-c $(BuildConfiguration) -o $(Build.StagingDirectory)/ci-build --no-build --self-contained -r $(runtime)'
zipAfterPublish: false
# Archive the /staging/ci-build folder to /staging/RemoteData.<BuildNumber>
- task: ArchiveFiles#2
inputs:
rootFolderOrFile: '$(Build.StagingDirectory)/ci-build'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/RemoteData.$(Build.BuildNumber).zip'
replaceExistingArchive: true
# Publish the zipfile as artifact
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/RemoteData.$(Build.BuildNumber).zip'
ArtifactName: 'RemoteData.$(Build.BuildNumber)'
publishLocation: 'Container'
This has the added benefit of being able to more closely manage your jobs:
As you can see each step is laid out separately here.
dotnet publish task copy file in the output and zip this folder. You can output to folder with a suffix like :
- task: DotNetCoreCLI#2
displayName: 'dotnet build'
inputs:
command: 'build'
projects: '$(solution)'
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
command: publish
publishWebProjects: False
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/app_v1.5.7'
zipAfterPublish: True
- task: PublishBuildArtifacts#1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'MyTool_LatestBuild'
You can define a build number and replace the suffix with :
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/run-number?view=azure-devops&tabs=yaml
...
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
command: publish
publishWebProjects: False
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/app_$(Build.BuildNumber)'
zipAfterPublish: True
...
Edit: see end of the post for working yaml.
I'm trying to publish a .NET Core 3.1 Console App as single file however I can't seem to succeed through Azure Devops Pipelines:
Self-contained or not, the publish result is always a bunch of dll instead of just being my executable.
Publishing as single fine works just fine on my computer (publishing from VS or the .NET Core CLI with the params I've set in the yaml below)
Here's the yaml responsible for the build:
# 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:
- feature/linux
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet#2
displayName: 'Use .Net Core sdk 3.1.x'
inputs:
version: 3.1.x
- task: DotNetCoreCLI#2
displayName: 'dotnet restore'
inputs:
command: restore
projects: './Project/Project.csproj'
feedsToUse: config
nugetConfigPath: ./NuGet/NuGet.Config
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
projects: './Project/Project.csproj'
arguments: '-o $(build.artifactstagingdirectory) -r linux-x64 -c Release -f netcoreapp3.1 -p:PublishSingleFile=true -p:SelfContained=false'
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
Solution:
I'm dumb, simply forgot the command part under dotnet publish.. the resulting command by default is build.
Note that you need to also specify
publishWebProjects: false
For a console project, see full working 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:
- feature/linux
pool:
vmImage: 'ubuntu-latest'
steps:
- task: DotNetCoreCLI#2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '**/Project.csproj'
feedsToUse: config
nugetConfigPath: ./NuGet/NuGet.Config
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
command: 'publish'
publishWebProjects: false
projects: '**/Project.csproj'
modifyOutputPath: true
arguments: '-o $(build.artifactstagingdirectory) -r linux-x64 -c Release -f netcoreapp3.1 -p:PublishSingleFile=true -p:SelfContained=false'
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
artifactName: 'drop'
PathtoPublish: '$(build.artifactstagingdirectory)'
Any help is welcome :)
It would be very weird the same commands to produce different results locally and on the remote server.
You use the same SDK, it does not make any sense. The problem is somewhere else in the pipeline. I would suggest the following solutions.
1) Try to explicitly state the which folder to publish when publishing build artifacts, it seems like it is trying to publish the linux-x64 folder (one folder up). Like:
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
artifactName: 'drop'
PathtoPublish: '$(build.artifactstagingdirectory)'
2) Try instead of PublishSingleFile to zipAfterPublish. Like:
- task: DotNetCoreCLI#2
displayName: Publish
inputs:
command: publish
modifyOutputPath: true
arguments: '--configuration $(BuildConfiguration) --output "$(build.artifactstagingdirectory)"'
zipAfterPublish: true
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
projects: './Project/Project.csproj'
artifactName: 'drop'
PathtoPublish: '$(build.artifactstagingdirectory)'
I hope it helps...
Updated Answer
You need to specify in the publish task the command like command: publish.
yaml worked for me is:
# 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:
- feature/linux
pool:
vmImage: 'ubuntu-latest'
steps:
- task: DotNetCoreCLI#2
displayName: 'Restore Nuget Packages'
inputs:
command: 'restore'
projects: './Project/Project.csproj'
feedsToUse: config
nugetConfigPath: ./NuGet/NuGet.Config
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
command: publish
modifyOutputPath: true
arguments: '--configuration Release --output "$(build.artifactstagingdirectory)"'
zipAfterPublish: true
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
artifactName: 'drop'
PathtoPublish: '$(build.artifactstagingdirectory)'
By adding the explicitly the publish command in the publish task I confirmed that a zip file created as an artifact.
I've tested your .yml file, the log showed dotnet build not dotnet publish. You could try the following code:
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
projects: '**/*.csproj'
arguments: '--configuration Release --output "$(build.artifactstagingdirectory)"'
modifyOutputPath: true
zipAfterPublish: true
Or
- task: DotNetCoreCLI#2
inputs:
command: 'custom'
projects: '**/*.csproj'
custom: 'publish'
arguments: '--configuration Release --output $(build.artifactstagingdirectory)'
I'm trying to migrate my small OSS project from AppVeyor to Azure DevOps and got almost everything done but now getting this error on the dotnet restore step:
NU1100: Unable to resolve 'System.Reflection.TypeExtensions (>= 4.5.1)' for '.NETStandard,Version=v1.3'.
Spite I clearly see that System.Reflection.TypeExtensions supports .NET Standard 1.3:
.NETStandard 1.3
System.Reflection (>= 4.3.0)
System.Resources.ResourceManager (>= 4.3.0)
System.Runtime (>= 4.3.0)
What I'm doing wrong?
Update: my YAML file looks like this:
trigger:
- master
pool:
vmImage: 'windows-2019'
variables:
solution: 'JWT.sln'
buildConfiguration: 'Release'
buildPlatform: 'Any CPU'
dotNetVersion: '2.2.106'
steps:
- task: DotNetCoreInstaller#0
displayName: Install .NET Core v$(dotNetVersion)
inputs:
version: $(dotNetVersion)
- task: DotNetCoreCLI#2
displayName: 'Restore NuGet packages'
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: config
nugetConfigPath: NuGet.config
- task: DotNetCoreCLI#2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(solution)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI#2
displayName: Run .NET Core tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.Core.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI#2
displayName: Run .NET Framework tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.NetFramework.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI#2
displayName: Package NuGet package
inputs:
command: pack
packagesToPack: 'src/**/*.csproj'
configuration: $(BuildConfiguration)
nobuild: true
- task: PublishBuildArtifacts#1
displayName: Publish build artifacts
Update 2: I tried to restore packages for .NET Core and .NET Framework separately but it didn't work:
displayName: 'Restore NuGet packages for .NET Core'
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: config
nugetConfigPath: NuGet.config
- task: NuGetCommand#2
displayName: 'Restore NuGet packages for .NET Framework'
inputs:
command: 'restore'
restoreSolution: $(solution)
feedsToUse: config
nugetConfigPath: NuGet.config
- task: DotNetCoreCLI#2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(solution)'
configuration: '$(buildConfiguration)'
What works though is raw MSBuild which restores packages explicitly:
- task: MSBuild#1
displayName: Build solution
inputs:
solution: $(solution)
msbuildArguments: /restore /t:build /p:CreatePackage=true /p:NoPackageAnalysis=true /p:PackageOutputPath=$(Build.ArtifactStagingDirectory)\artifacts
configuration: $(BuildConfiguration)
maximumCpuCount: true
I think that your dotnet restore task is not a dotnet restore but somehow an msbuild / NuGet restore?
In particular, from the last 20 lines of the log, I hypothesise that this error has nothing to do with this package, it's just that this package was the very first one it tried to restore, so this is where it errored and the real issue is more a variant on https://github.com/NuGet/Home/issues/4821 kind of thing.
Diagnostic step 1: change the build agent container to one without visual studio and see if that fixes the restore error.
I'm certainly confident that (1) the restore step is redundant for dotnet core toolchain and and (2) you must be using the dotnet core toolchain to build on your dev desktops?
So I think the issues in moving to Azure may be, (1) it isn't obvious how to build the right pipeline and (2) there may be some bugs in dotnet core/msbuild/nuget interactions.
If you use the GUI options, then the only tasks you want are dotnet core tasks
If you use the YML option, then start off by picking only snippets extracted from https://learn.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core. The snippets on that page are equivalent to running dotnet commands on your local machine so can be debugged somewhat on local machine.
Here's I ended up having working:
trigger:
- master
pool:
vmImage: 'windows-2019'
variables:
solution: 'JWT.sln'
buildConfiguration: 'Release'
buildPlatform: 'Any CPU'
coreVersion: '2.2.106'
nugetVersion: '4.9.4'
steps:
- task: DotNetCoreInstaller#0
displayName: Install .NET Core v$(coreVersion)
inputs:
version: $(coreVersion)
- task: DotNetCoreCLI#2
displayName: 'Restore NuGet packages for .NET Core'
inputs:
command: 'restore'
projects: '**/*.csproj'
- task: NuGetToolInstaller#0
displayName: Install NuGet v$(nugetVersion)
inputs:
versionSpec: $(nugetVersion)
checkLatest: true
- task: NuGetCommand#2
displayName: 'Restore NuGet packages for .NET Framework'
inputs:
command: 'restore'
restoreSolution: $(solution)
- task: DotNetCoreCLI#2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(solution)'
arguments: '-c $(buildConfiguration)'
- task: DotNetCoreCLI#2
displayName: Run .NET Core tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.Core.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI#2
displayName: Run .NET Framework tests
inputs:
command: 'test'
projects: 'tests/**/JWT.Tests.NetFramework.csproj'
arguments: ' -c $(buildConfiguration) --no-build --no-restore'
testRunner: VSTest
testResultsFiles: '**/*.trx'
testResultsFormat: 'xUnit'
failTaskOnFailedTests: true
- task: DotNetCoreCLI#2
displayName: Package NuGet package
inputs:
command: pack
packagesToPack: 'src/**/*.csproj'
configuration: $(BuildConfiguration)
nobuild: true
- task: PublishBuildArtifacts#1
displayName: Publish build artifacts