Exclude MsBuild target from intellisense build

36 Views Asked by At

I have added a custom target to a .csproj file.

I would like that target not to be invoked when the build is run by Visual Studio to provide input to Intellisense.

I have searched for a property that I could use as a condition with no luck. I was expecting to end up with something like:

<Target Name="MyCustomTask" BeforeTargets="PrepareForBuild" Condition="'$(RunningFromIntellisense)'!='true'">
    <!-- Do something here -->
</Target>

Is there any way to detect that the build is running in that context?

1

There are 1 best solutions below

0
Bowman Zhu-MSFT On BEST ANSWER

Is there any way to detect that the build is running in that context?

VS doesn't have such a dedicated property to check the IntelliSense behavior you mentioned.

$(DesignTimeBuild) that Jonathan mentioned is a possible way that may suitable for you, but this property is not only affected by IntelliSense. Other design time operations also can meet that opportunity(Which means it could affected in other time).

You can take a look of this official document:

Design-time builds