Skip to content

What is the best practice to exclude certain targets when in test? #6619

Answered by rainersigwald
anddrzejb asked this question in Q&A
Discussion options

You must be logged in to vote

A few comments:

These are completely useless during tests, so I would like to skip them, when tests are executed.

Can you instead add incremental build support for those things so that they are skipped when not necessary, either with MSBuild-level Inputs and Outputs around the Task or with Gulp's incremental functionality? That will help for non-test build scenarios too.

I tried with passing a variable to the project like this from my Tests.csproj

<Project Sdk="Microsoft.NET.Sdk.Razor" InitialTargets="InformAboutTest">

  <Target Name="InformAboutTest" BeforeTargets="Build">
    <MSBuild Projects="MyProject.csproj" Properties="IsUnderTest=true;" />
  </Target>

Does this project also …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@anddrzejb
Comment options

Answer selected by anddrzejb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants