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 8668259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:10:09+00:00 2026-06-12T18:10:09+00:00

I have a MSBuild *.proj file that builds my solution and sets build’s version

  • 0

I have a MSBuild *.proj file that builds my solution and sets build’s version using a changeset number.
Now I need to make two builds of the same solution, with one difference between:
version of the first should be i.e. “5.0.0.{chanset_number}”, but version of the second – “2.0.0.{chanset_number}”.

I use the following code to get a number of the latest changeset and to set version of a build:

<ItemGroup>
  <FilesToVersion Include="$(SolutionRoot)\GUI\Properties\AssemblyInfo.cs" />
</ItemGroup>
<!-- Added for using the latest changeset id as build number -->
<Target Name="BuildNumberOverrideTarget">
  <BuildNumberGenerator>
    <Output TaskParameter="BuildNumber" PropertyName="BuildNumber" />
  </BuildNumberGenerator>
  <GetLatestChangeset>
    <Output TaskParameter="LatestChangeset" PropertyName="LatestChangeset" />
  </GetLatestChangeset>
</Target>
<Target Name="AfterGet" Condition="'$(IsDesktopBuild)'!='true' ">
  <MSBuild.ExtensionPack.VisualStudio.TfsVersion 
     TaskAction="SetVersion" Files="%(FilesToVersion.Identity)"
     Version="$(VersionMajor).$(VersionMinor).$(VersionService).$(LatestChangeset)" 
AssemblyVersion="$(VersionMajor).$(VersionMinor).$(VersionService).$(LatestChangeset)"
SetAssemblyVersion="true" />
</Target>
  • 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-06-12T18:10:10+00:00Added an answer on June 12, 2026 at 6:10 pm

    Adding a PropertyGroup may help here.

    <PropertyGroup>
        <MyVersionMajor Condition="$(MyVersionMajor)==''">$(VersionMajor)</MyVersionMajor>
    </PropertyGroup>
    

    This will set a property called MyVersionMajor to the VersionMajor property if you do not explicitly set it via an MSBuild Parameter.

    To set MyVersionMajor as an MSBuild parameter add the following to your MSBuild Command

    MSBuild.exe <yourprojectfile> /p:MyVersionMajor=2
    

    You now need to change the build target to include your new property:

    <Target Name="AfterGet" Condition="'$(IsDesktopBuild)'!='true' ">
      <MSBuild.ExtensionPack.VisualStudio.TfsVersion 
         TaskAction="SetVersion" Files="%(FilesToVersion.Identity)"
         Version="$(MyVersionMajor).$(VersionMinor).$(VersionService).$(LatestChangeset)" 
    AssemblyVersion="$(MyVersionMajor).$(VersionMinor).$(VersionService).$(LatestChangeset)"
    SetAssemblyVersion="true" />
    </Target>
    

    Ensuring your new Property group appears before this target.

    When you run MSBuild against this project without specifying the parameter you should get "5.0.0.{changeset_number}" and when you specify the parameter you would get "2.0.0.{changeset_number}"

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

Sidebar

Related Questions

I have been using a msbuild file that builds and packages my solution to
I have the following proj file: <?xml version=1.0 encoding=utf-8?> <Project ToolsVersion=4.0 DefaultTargets=Build xmlns=http://schemas.microsoft.com/developer/msbuild/2003> <PropertyGroup>
I have a current build using teambuild/msbuild that I need to integrate a wix
I have a msbuild script that builds multiple projects using TeamCity. It builds a
I have a shared properties file shared.properties.proj <Project xmlns=http://schemas.microsoft.com/developer/msbuild/2003> <PropertyGroup> <SharedAssemblySearch>$(MSBuildProjectDirectory)\..\Shared Assemblies</SharedAssemblySearch> <ParentDir>..</ParentDir> <SharedAssemblySearch
I am using Team City as the build server, and I have a msbuild
I use the TFS 2008 build facilities. I have a large MSBuild project (TFSBuild.proj)
In MsBuild it is possible to create a build.proj.user file which is parsed by
I have an msbuild script that runs on Team Foundation build. One of the
I have the following MSBuild project file: <?xml version=1.0 encoding=utf-8?> <Project xmlns=http://schemas.microsoft.com/developer/msbuild/2003 DefaultTargets=Deploy ToolsVersion=4.0>

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.