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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:52:25+00:00 2026-05-20T01:52:25+00:00

Since I started using MSBuild for our projects, I’ve created several .proj scripts that

  • 0

Since I started using MSBuild for our projects, I’ve created several .proj scripts that are shared by several projects in our repository. All these shared scripts reside in a single directory.

So far I’ve been referring to the shared scripts by using a relative path, something like this:

<MSBuild Projects="..\..\common\build\MyScriptA.proj" Properties="ABC=XYZ"/>

However, every project also imports a common .proj script like so:

<Import Project="..\..\common\build\CommonImports.proj"/>

which <Import>s several other things and defines some properties.

This morning I thought I could replace the relative path with a variable, perhaps $(CommonDir), which would be defined by importing the CommonImports.proj mentioned above. This would enable me to call the common tasks like this:

<MSBuild Projects="$(CommonDir)\MyScriptA.proj" Properties="ABC=XYZ"/>

However, I can’t figure out a way to define this $(CommonDir) variable in such a way as to make it work in all other MSBuild scripts that import CommonImports.proj, regardless of their location.

This question offers several ways of creating a property containing an absolute path from a relative path, but none of those seem to work if all I do is <Import> the script defining the property.

Question 1: I’m fairly new to MSBuild; is there a better way of creating a “library” of reusable .proj scripts I could run via the <MSBuild> task? I am aware of $(MSBuildExtensionsPath), however I would like the common tasks to reside in my checkout so that our build machine would automatically get the latest versions of the common tasks whenever it performs a checkout.

Question 2: How do I define $(CommonDir) inside CommonImports.proj so as to make it contain the absolute path to the directory containing CommonImports.proj?

  • 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-20T01:52:25+00:00Added an answer on May 20, 2026 at 1:52 am

    Here’s what’s worked best for us.

    First, check in all reusable stuff into a /common/build/ directory in the VCS.

    Then, add a /common/build/CommonImports.proj, looking something like this:

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
             ToolsVersion="4.0">
      <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
      <Import Project="ILMerge.proj"/>
      <Import Project="Mage.proj"/>
      <Import Project="InnoSetup.proj"/>
      <UsingTask TaskName="RT.Tasks.AssemblyVersion" AssemblyFile="Tasks\Release\RT.Tasks.dll"/>
      <UsingTask TaskName="RT.Tasks.WaitForProcessesToTerminate" AssemblyFile="Tasks\Release\RT.Tasks.dll"/>
      <PropertyGroup>
        <BuildSingleProj>$(Root)\common\build\BuildSingle.proj</BuildSingleProj>
      </PropertyGroup>
    </Project>
    

    This imports a few projects and tasks that everything uses, and defines a property group that is shared by everything. Then, add this in every build script:

    <PropertyGroup>
      <Root>..\..</Root>
      [... other global properties ...]
    </PropertyGroup>
    <Import Project="$(Root)\common\build\CommonImports.proj"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ever since I started using .NET, I've just been creating Helper classes or Partial
Since I have started using this site, I keep hearing about the Boost library.
Since I've started using NetBeans, I've learned of some powerful ways to abstract away
Since I started studying object-oriented programming, I frequently read articles/blogs saying functions are better,
Since I started learning F# and OCaml last year, I've read a huge number
I work in a very small shop (2 people), and since I started a
Since I've started my first job as a professional software developer about two years
Since I've started to use jQuery, I have been doing a lot more JavaScript
Here is a problem I've struggled with ever since I first started learning object-oriented
Since CS3 doesn't have a web service component, as previous versions had, is there

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.