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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:32:56+00:00 2026-05-13T13:32:56+00:00

In my MSBuild script I need to pass the full directory as a parameter.

  • 0

In my MSBuild script I need to pass the full directory as a parameter. How can I get it?

Example: I am running the script from C:\dev, and I want a relative path, temp, so I am after C:\dev\temp.

Note: I don’t know from which folder the script will be run.

  • 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-13T13:32:56+00:00Added an answer on May 13, 2026 at 1:32 pm

    Igor is pretty close. MSBuildProjectDirectory is the property that will give you the full path to the project file which was invoked on the command line. So if you have the following scripts:

    • C:\temp\MyProj.proj
    • C:\shared\shared.targets

    And MyProj.proj imports shared.targets and this is the one passed to msbuild.exe then the value for MSBuildProjectDirectory will always be C:\temp even if you are referencing that inside of shared.targets. If your shared.targets requires path knowledge then those should be declared in known properties. For example C# project files define the value for OutputPath and the shared file Microsoft.Common.targets uses that property.

    Edit: MSBuild 4

    If you are using MSBuild 4, you can also use these properties for this type of value.

    • MSBuildThisFile
    • MSBuildThisFileDirectory
    • MSBuildThisFileDirectoryNoRoot
    • MSBuildThisFileExtension
    • MSBuildThisFileFullPath
    • MSBuildThisFileName

    See http://sedodream.com/2010/03/11/MSBuild40ReservedProperties.aspx.

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

Sidebar

Related Questions

I can't seem to find how to create an MSBuild script from within Visual
I'm trying to write an MsBuild script to zip some files up. I need
I'm trying to create a MSBuild script for running in TeamCity. I have a
I want to make a target in my MSBuild script that: Fetch SVN revision/datetime
I'm attempting to execute MSBuild from a NAnt script (which is called by CruiseControl.NET).
I'm writing my first CI script using MSBuild and I want to everyone that
I'm trying to get an exec task inside an msbuild script to work and
I need to construct an MSBUILD script executes .SQL Scripts which have changed since
i am working with msbuild script.i want to comment particular line using regular expression
I've now setup a MSBuild script to create the folders and files I need

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.