0
votes

I have a single .NET solution with multiple class library projects, each one is published as a nuget feed using azure-devops.

Then I have an azure-devops build pipeline, with steps to Restore, Build, Publish, Pack and Push. The first 4 steps are setup for **/.csproj and the last is a $(Build.ArtifactStagingDirectory)/.nupkg with the target feed.

I have everything set up and working, except if you make a change to just one project, it builds ALL projects because of the **/*.csproj.

This is no good for nuget packages, as it increments every project's version number and they all appear as having an update available in the nuget package manager.

My Question: Is there a way to do this so that only the project(s) with changes go through the process?

1
In my experience with monorepos, the solution is usually the smallest unit of release - can you describe your reasoning for wanting a single solution with multiple, differently-versioned deployable projects?brnlmrry
How about the issue? Does the answer below resolved your question, If yes, you you could Accept it as an Answer , so it could help other community members who get the same issues and we could archive this thread, thanks. If not, please let us know if you would like further assistance.Leo Liu-MSFT

1 Answers

1
votes

Is there a way to do this so that only the project(s) with changes go through the process?

The answer is yes.

The solution is use the private agent to build your solution instead of the hosted agent.

That because every time the hosted agent assigned to us is a clean machine, VS/MSbuild will build all the projects for the setting **/* csproj. So, to resolve this issue, we must save the results of the last build to achieve incremental builds.

So, to resolve this issue, we need to set up a private agent to build those projects and do not clean the working directory of your private agent before the build is run:

Set the Clean option to false on the Get sources:

enter image description here

Note: Since you also set the **/*.csproj for the task nuget push, if the project not modified, this command will push the same version to the feed, it will throw the conflict error, you need enable Allow duplicates to be skipped on the nuget push task:

enter image description here

Hope this helps.