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

  • Home
  • SEARCH
  • 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 1898414
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:45:43+00:00 2026-05-17T06:45:43+00:00

I read John Robbins’ article TFS 2010 Build Number and Assembly File Versions: Completely

  • 0

I read John Robbins’ article TFS 2010 Build Number and Assembly File Versions: Completely In Sync with Only MSBuild 4.0, and I’m wondering about the best way to go about integrating this.

The download for the article has two files, one is a targets file and one is a proj file.

The targets file has a number of tasks to scrape out a build number based on the Tfs build number (the same one used for the builds) and write that number out to some location (call it BuildNumberFile) for consumption by other proj files.

The proj file is very simple. It just imports the aforementioned targets file, and then declares a target with name “All” while also declaring DefaultTargets on the Project element to be All as well.

    <Project ToolsVersion="4.0" DefaultTargets="All" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <PropertyGroup>
            <!-- The two required properties so the Wintellect.TFSBuildNumber tasks knows your major and minor values.-->
            <TFSMajorBuildNumber>3</TFSMajorBuildNumber>
            <TFSMinorBuildNumber>1</TFSMinorBuildNumber>
        </PropertyGroup>

        <Import Project="Wintellect.TFSBuildNumber.targets"/>

        <!-- Just ask for the version information files you need. These are here to show all the diffent ones in 
           Wintellect.TFSBuildNumber.Targets. You can change the names -->
        <Target Name="All"
              DependsOnTargets="WriteSharedCSharpAssemblyVersionFile;
                              WriteSharedVBAssemblyVersionFile;
                              WriteSharedCPPCLIAssemblyVersionFile;
                              WriteSharedCPPAssemblyVersionFile;
                              WriteSharedWiXAssemblyVersionFile;
                              WriteSharedTextAssemblyVersionFile;"/>
    </Project>

I have two questions about this:

  • I’m still learning MSBuild. If the name of the target isn’t specified elsewhere in the targets, is the target executed? How do I ensure that this target is run?
  • Are the csproj files supposed to declare an Include item for the location where BuildNumberFile is, even though it doesn’t exist until compiletime?
  • Do ItemGroups and Include have a DependsOnTargets or something that allows them make sure the file exists before they build?
  • Are the entire contents of the csproj file using this supposed to be wrapped in a target that expresses DependsOnTargets for BuildNumberFile?

Thanks!

  • 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-17T06:45:44+00:00Added an answer on May 17, 2026 at 6:45 am

    I think I’ve got this figured out, but two people promoted my question so I’ll answer it here:

    • You can ensure that a target is run by expressing a dependency on it from another target. Microsoft.Common.targets exposes two targets–BeforeBuild and AfterBuild–expressly for the purpose of being overridden for customizability. I found the easiest way to do this was <Target Name="BeforeBuild" DependsOnTargets="WriteSharedCSharpAssemblyVersionFile" /> where WriteSharedCSharpAssemblyVersionFile is the target declared in the download from the link in the original post. Also, if you’re new to MSBuild, this BeforeBuild target must be declared after the Microsoft.CSharp.targets is imported, but the default csproj template guides you in doing this.

    • The WriteSharedCSharpAssemblyVersionFile target should indeed write the file to some central location, since when building a solution, all targets are executed only once. All projects should reference the file from that location even if it doesn’t exist, since by the time compilation happens (or more importantly, by the time references are resolved), the BeforeBuild target will have run and the file will be in place.

      • In my structure, I have these versioning files in a folder directly underneath the branch root folder. Furthermore, since the file being built is generated, I have it build to the output directory. It seems a little strange to be referencing things from the output, but it preserves the invariant of having all build products in one place so that the output directory can be blown away as a means of performing a clean.
    • In MSBuild items constitute inputs into the system (usually files) so it’s weird to think of them depending on targets. After some learning this question doesn’t make a lot of sense. In any case, the answer is no.

    • The entire contents of the file should indeed not be all in one target–all that is required is to import the Wintellect.TFSBuildNumber.targets file at the beginning of your csproj file, and declare BeforeBuild’s dependency on WriteSharedCSharpAssemblyVersionFile at the end.

    Hope this helps!

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

Sidebar

Related Questions

No related questions found

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.