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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:38:41+00:00 2026-06-01T04:38:41+00:00

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

  • 0

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 Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
    <SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
    <SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
    <SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
    <SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
    <SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
    <SharedAssemblyPath Condition="Exists('$(SharedAssemblySearch)')">$(SharedAssemblySearch)</SharedAssemblyPath>
    <SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">..\SharedAssemblies</SharedAssemblySearch>
    <SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
    <SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
    <SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
    <SharedAssemblySearch Condition="!Exists('$(SharedAssemblySearch)')">$(ParentDir)\$(SharedAssemblySearch)</SharedAssemblySearch>
    <SharedAssemblyPath Condition="Exists('$(SharedAssemblySearch)')">$(SharedAssemblySearch)</SharedAssemblyPath>
 </PropertyGroup>
</project>

I am searching for whatever level parent directory contains the directory named Shared Assemblies. or alternatively SharedAssemblies

I’d like to put this code in a central location for the sln, so that all the projects can just import it. projects in the sln are not all at the same hierarchy level.

Sample .csproj

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Shared.Properties.proj))\Shared.Properties.proj"
   Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Shared.Properties.proj))' != '' "/>
    <ItemGroup>
    <Reference Include="EntityFramework">
      <HintPath>$(SharedAssemblyPath)\NuGet\EntityFramework.4.3.0\lib\net40\EntityFramework.dll</HintPath>
     </Reference>
    </ItemGroup>
  <Target Name="CheckReferencePaths" BeforeTargets="ResolveAssemblyReferences">
    <Message Importance="high" Text="Doing CheckReferencePaths" />
    <ItemGroup>
     <SharedAssemblyPathItem Include="$(SharedAssemblyPath)" />
    </ItemGroup>
    <Warning Condition="!Exists('@(SharedAssemblyPathItem)')" Text="SharedAssemblyPath not found at '@(SharedAssemblyPathItem)'" />
    <Warning Condition="!Exists('@(SharedAssemblyPathItem)')" Text="SharedAssemblyPath not found at '@(SharedAssemblyPathItem->'%(FullPath)')'" />
    <Message Condition="!Exists('%(Reference.HintPath)')" Text="FullPath=%(Reference.HintPath)" Importance="high" />

I have this working in the main project without pushing the property group out to a satellite file that I import, but now want to make it reusable between other projects that could have shared references.

The BeforeTargets target shows this on the new attempt that is not working:

CheckReferencePaths:
Doing CheckReferencePaths
D:\projects\Team\Project\Adapters\DbAdapter\dbadapter.csproj(103,5):
warning : SharedAssemblyPath not found at ”
D:\projects\Team\Project\Adapters\DbAdapter\dbadapter.csproj(104,5):
warning : SharedAssemblyPath not found at ”
FullPath=\NuGet\EntityFramework.4.3.0\lib\net40\EntityFramework.dll
FullPath=

How can I get the project file that imports the shared to evaluate the imported project’s properties before it evaluates the item groups’ hintpaths. Or is the evaluation order proper, but something else in my construction is incorrect?

  • 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-01T04:38:42+00:00Added an answer on June 1, 2026 at 4:38 am

    Your question lead me to find this valuable info on MSDN. I’m posting it here for keeping the answer self-contained.


    Order of Evaluation

    When MSBuild reaches an Import element, the imported project is effectively inserted into the importing project at the location of the Import element. Therefore, the location of the Import element can affect the values of properties and items. It is important to understand the properties and items that are set by the imported project, and the properties and items that the imported project uses.

    When the project builds, all properties are evaluated first, followed by items. For example, the following XML defines the imported project file MyCommon.targets:

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <PropertyGroup>
            <Name>MyCommon</Name>
        </PropertyGroup>
    
        <Target Name="Go">
            <Message Text="Name='$(Name)'"/>
        </Target>
    </Project>
    

    The following XML defines MyApp.proj, which imports MyCommon.targets:

    <Project
        DefaultTargets="Go"
        xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <PropertyGroup>
            <Name>MyApp</Name>
        </PropertyGroup>
        <Import Project="MyCommon.targets"/>
    </Project>
    

    When the project builds, the following message is displayed:

    Name=”MyCommon”

    Because the project is imported after the property Name has been defined in MyApp.proj, the definition of Name in MyCommon.targets overrides the definition in MyApp.proj. If, the project is imported before the property Name is defined, the build would display the following message:

    Name=”MyApp”

    Use the following approach when importing projects

    1. Define, in the project file, all properties and items that are used
      as parameters for properties and items in the imported project.

    2. Import the project.

    3. Define in the project file all properties and items that must
      override default definitions of properties and items in the imported
      project.

    Example

    The following code example shows the MyCommon.targets file that the second code example imports. The .targets file evaluates properties from the importing project to configure the build.

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <PropertyGroup>
            <Flavor Condition="'$(Flavor)'==''">DEBUG</Flavor>
            <Optimize Condition="'$(Flavor)'=='RETAIL'">yes</Optimize>
            <appname>$(MSBuildProjectName)</appname>
        <PropertyGroup>
        <Target Name="Build">
            <Csc Sources="hello.cs"
                Optimize="$(Optimize)"
                OutputAssembly="$(appname).exe"/>
        </Target>
    </Project>
    

    The following code example imports the MyCommon.targets file.

    <Project DefaultTargets="Build"
        xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <PropertyGroup>
            <Flavor>RETAIL</Flavor>
        </PropertyGroup>
        <Import Project="MyCommon.targets"/>
    </Project>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a multi module maven project. Now I have shared the project
I have extended my domain service using a shared code file to add an
I have a Visual Studio 2008 project that produces a file called: Game-Release.exe .
I have four classes which share some arrangement of four properties. I have currently
I have shared hosting on CentOS with local MySQL database. I'm able to run
In .net we are not allowed to have shared function/methods in abstract classes and
For several applications I made for my current client I have shared user accounts.
Over the last few months/years, I have shared a folder or two with numerous
I have a shared library that I wish to link an executable against using
I have a shared development server with many virtual directories running off one of

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.