Reputation: 1533
Currently, I have a pipeline set up for this .NET Core solution, composed of several project apps, but I'm building each "deliverable project" independently (REST APIs, gRPC APIs, ASP.NET Core MVC apps and so on - one dotnet restore
, dotnet build
, dotnet test
, dotnet publish
, docker build
and docker push
tasks for each executable in this solution). It works.
Each "project sub-pipeline" is an "Agent Job" inside of the main pipeline. It's required by the client that I build the projects with the win-x64
RID and pack each App/API in Windows Containers (dotnet CLI doesn't allow passing a RID to build a whole solution - error NETSDK1134).
The question is: How could I do a single restore/build/test cycle for the whole solution (to improve build time) and only have the publish steps separated for each project?
I'm aware of this question but I think it is a different thing. Could you guys point me to some docs where I could find more info related to my case?
I researched a bit about MSBuild Publish Profiles and custom MSBuild projects but didn't manage to find something similar.
Thank you in advance.
Upvotes: 1
Views: 2184
Reputation: 40899
If you want to do a single restore/build/test
you need to publish your whole source folder as an artifact then in your artifact you will get your code and build assemblies. Then reuse this artifact for later steps. It could look like:
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
feedsToUse: 'select'
vstsFeed: 'my-vsts-feed' # A series of numbers and letters
- task: DotNetCoreCLI@2
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI@2
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(System.DefaultWorkingDirectory)'
artifactName: 'solution'
then on deployment job you will get whole solution with restored packages and build code ready for further steps.
Regarding .NET RID as far as I see here you have two options:
--runtime
to dotnet buildUpvotes: 2