Avoid Project B and C being built in Azure Devops (Visual Studio - .NET 7)

31 Views Asked by At

I have a problem I hope you can help me with.

We create different solutions which are all based on a “skeleton structure” for Visual Studio. About the structure:

A solution consists always of at least 3 projects: Project A is a class library (C# - .NET7) (should always build). Project B is a an ASP.NET project (.NET 7) (Should only build on local computer – never in DevOps). Project C is also an ASP.NET project (.NET 7) which only contains Razor Pages (Should never Build).

Sometimes where is also included a project D, E etc. They should always build.

Project B is an ecommerce solution (standard). We need it locally for running the solution/debugging. It is included in DevOps – but we do not build it in DevOps since we don’t deploy it.

Project C is template files used for the ecommerce solution. We do not build the solution – but we do copy the files to the artifact files – and deploy them.

My problem is – how do I set it up, so project C is never build locally and project B and C is not build in DevOps when taking into account - that if a developer add Project D to the solution when it is automatically build locally and in DevOps without the developer needs to do anything other than just adding a project to the solution in Visual Studio?

1

There are 1 best solutions below

0
On

When building in Azure DevOps pipeline, you can try to use the .NET Core task to with the following file matching patterns.

**/*.csproj
!**/{name of project B}.csproj
!**/{name of project C}.csproj
  • The pattern "**/*.csproj" will match all the .csproj files.
  • The pattern "!**/{name of project B}.csproj" will exclude the .csproj file of project B.
  • The pattern "!**/{name of project C}.csproj" will exclude the .csproj file of project C.

See below example as reference.

- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    projects: |
     **/*.csproj
     !**/{name of project B}.csproj
     !**/{name of project C}.csproj

enter image description here