Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 631875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:00:53+00:00 2026-05-13T20:00:53+00:00

In our project files we are using StyleCop and are running it during the

  • 0

In our project files we are using StyleCop and are running it during the build process. We’ve modified our project files to include the StyleCop targets like so:

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
<Import Project="..\..\Tools\Microsoft\StyleCop\v4.3\Microsoft.StyleCop.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
     Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

The question is why does this work? Who is calling the StyleCop target defined in the Microsoft.StyleCop.targets file?

As far as I can tell, the only target being run when you start the build, is the “Build” target. I can’t find any references to the “StyleCop” target anywhere outside the Microsoft.StyleCop.targets file. So again, why is it being called?

The reason I want to know is because it would be cool if we could do something similar for our own custom tasks. So instead of editing all of our 78 csproj files, we could just import our own general target like:

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
<Import Project="Common.targets" />

And then just import StyleCop in that file instead, along with all our other tasks that need to be done on a per project basis.

Please help me understand.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:00:54+00:00Added an answer on May 13, 2026 at 8:00 pm

    Eureka!

    The secret sauce is the following lines in the StyleCop targets file:

    <PropertyGroup>
      <BuildDependsOn>$(BuildDependsOn);StyleCop</BuildDependsOn>
      <RebuildDependsOn>StyleCopForceFullAnalysis;$(RebuildDependsOn)</RebuildDependsOn>
    </PropertyGroup>
    

    The “Build” target in Microsoft.Common.targets is declared like so:

    <Target Name="Build"
            Condition=" '$(_InvalidConfigurationWarning)' != 'true' "
            DependsOnTargets="$(BuildDependsOn)"
            Outputs="$(TargetPath)" />
    

    This means that any target listed in the “BuildDependsOn” property will get called during the build. Isn’t that nice? 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using NHibernate in our project and need all .hbm.xml files to be
We want to be able to deploy our project using Hudson, but the build
We have just started using requirejs in our project and we are loving it.
We are using Oracle 10g database, NHibernate, WCF and Silverlight 3.0 in our project
We are using a Cab Builder project in VS2008 to generate our CF cab
Git Workflow Developer 1 (France) - Local Machine - Local Project Files - Local
Currently my team and I are working with Code Igniter 1.7.3 and we are
Developer A - Local Repository --> pulls/push ---> github Developer B - Local Repository
I am currently developing Java/GWT-application which is hosted on a weblogic application server. I
Here's the use case: A friend and I are building an Android app and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.