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

The Archive Base Latest Questions

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

Short version: I have an MSBuild project that imports another project. There is a

  • 0

Short version:

I have an MSBuild project that imports another project. There is a property holding a relative path in the imported project that is relative to the location of the imported project. How do I convert this relative path to be absolute? I’ve tried the ConvertToAbsolutePath task, but this makes it relative to the importing project’s location).

Long version:

I’m trying out Robert Koritnik’s MSBuild task for integrating nunit output into Visual Studio (see this other SO question for a link). Since I like to have all my tools under version control, I want the target file with the custom task in it to point to the nunit console application using a relative path.

My problem is that this relative path ends up being made relative to the importing project.

E.g. (in … MyRepository\Third Party\NUnit\MSBuild.NUnit.Task.Source\bin\Release\MSBuild.NUnit.Task.Targets):

...
  <PropertyGroup Condition="'$(NUnitConsoleToolPath)' == ''">
    <NUnitConsoleToolPath>..\..\..\NUnit 2.5.5\bin\net-2.0</>
  </PropertyGroup>  
...
  <Target Name="IntegratedTest">
    <NUnitIntegrated
      TreatFailedTestsAsErrors="$(NUnitTreatFailedTestsAsErrors)"
      AssemblyName="$(AssemblyName)"
      OutputPath="$(OutputPath)"
      ConsoleToolPath="$(NUnitConsoleToolPath)"
      ConsoleTool="$(NUnitConsoleTool)"
    />
  </Target>
...

The above target fails with the error that the file cannot be found (that is the nunit-console.exe file). Inside the NUnitIntegrated MSBuild task, when the the execute() method is called, the current directory is the directory of the importing project, so relative paths will point to the wrong location.

I tried to convert the relative path to absolute by adding these tasks to the IntegratedTest target:

<ConvertToAbsolutePath Paths="$(NUnitConsoleToolPath)">
  <Output TaskParameter="AbsolutePaths" PropertyName="AbsoluteNUnitConsoleToolPath"/>
</ConvertToAbsolutePath>

but this just converted it to be relative to the directory of the project file that imports this target file.

I know I can use the property $(MSBuildProjectDirectory) to get the directory of the importing project, but can’t find any equivalent for directory of the imported target file.

Can anyone tell me how a path in an imported file that is supposed to be relative to the directory that the imported file is in can be made absolute?

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-15T06:43:21+00:00Added an answer on May 15, 2026 at 6:43 am

    You’ll have to define your relative path with MSBuildProjectDirectory

    Importing project :

    <PropertyGroup>
      <RelativePathToProject>subdir\</RelativePathToProject>
    </PropertyGroup>
    
    <Import Project="$(RelativePathToProject)SubSample.proj"/>
    
    <Target Name="GetNUnitConsolePath">
      <Message Text="NUnitConsoleToolPath : %(NUnitConsoleToolPath.FullPath)"/>
    </Target>
    

    Imported project file :

    <ItemGroup>
      <NUnitConsoleToolPath 
         Include="$(MSBuildProjectDirectory)\$(RelativePathToProject)..\..\..\NUnit 2.5.5\bin\net-2.0"/>
    </ItemGroup>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Short version: I have a Django project under development & testing (not yet into
Short Version I have a list of int s that I need to figure
Short version: I have a similar setup to StackOverflow. Users get Achievements. I have
Short version of what I want to accomplish : I have a foot pedal
Short version: I want a way to run somefunction(username) and have it return the
Ok a short question: Is there any SIMPLE software with a GUI, that lets
Short version: How do I initialize and use DirectInput if I have no access
Short version: When two lists are adjacent to each other, is there a way
Short Version Is there a way to force (or provide a hint to) Microsoft
Short version: I want to trigger the Form_Load() event without making the form visible.

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.