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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:40:45+00:00 2026-06-05T03:40:45+00:00

I am trying to add a project and file reference to the same dll

  • 0

I am trying to add a project and file reference to the same dll in the csproj with the BuildingInVsideisualStudio property. But when they are in the csproj together, only the file reference is picked up. If I remove the file reference, it picks up the csproj. I have tried swapping the order, but no luck. Any ideas why this doesn’t work?

Here is the basic idea:

<ItemGroup Condition="'$(BuildingInsideVisualStudio)' == false">
    <Reference Include="MyNamespace.Mine">
        <HintPath>..\$(OutDir)\MyNamespace.Mine.dll</HintPath>
    </Reference>
</ItemGroup>
<ItemGroup Condition="'$(BuildingInsideVisualStudio)' == '' Or '$(BuildingInsideVisualStudio)' == true">
    <ProjectReference Include="..\MyNamespace.Mine.csproj">
        <Project>{GUID}</Project>
        <Name>MyNamespace.Mine</Name>
    </ProjectReference>
</ItemGroup>

Someone else has gone down this path, too, but it appears there are some caveats. I need to do this conditional because of my build process, which cannot change. Using the file reference forces me to lose the Go to Definition and Find All References (sorry, but I cannot install ReSharper to solve this either).

  • 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-05T03:40:47+00:00Added an answer on June 5, 2026 at 3:40 am

    Assuming I understood the question correctly after bit of experimentation it seems that naming them differently would solve most of the problems; msbuild would respect the condition and use assembly reference, VS would display them both in solution explorer but would prebuilt the reference as if it is project kind and would keep goto-definition without R# working. Conditional import is something else worth looking into but I haven’t tried it.

    <ItemGroup>
        <ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" Condition="'$(Foo)'=='Bar1'">
            <Project>{FD0E01BC-7777-4620-9EF2-5F60804B3173}</Project>
            <Name>ClassLibrary1-ProjRef</Name>
        </ProjectReference>
        <Reference Include="ClassLibrary1" Condition="'$(Foo)'=='Bar2'">
            <Name>ClassLibrary1-AssRef</Name>
            <HintPath>..\ClassLibrary1\bin\Debug\ClassLibrary1.dll</HintPath>
        </Reference>
    </ItemGroup>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a service reference to my silverlight project from a file
I'm trying to add the T4MVC templates to my project, but I'm experiencing some
I'm trying to reference another Xcode4 project within Xcode4 but having troubles - what's
I get a warning trying to add a Cloud Service Reference from another project
I am trying to add my project under source control. I am using Microsoft
I'm trying to add Elmah to my MVC3 project. After installing via Nuget, when
So I'm trying to add some ability to my project to allow user-defined properties
I'm trying to add a navigational menu for my project which uses the ASP.NET
I am trying to add groovy to an existing Java Maven project that leverages
I'm trying to add a new ADO.Net Entity Data Model to an MVC project

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.