The value of the BuildingInsideVisualStudio property does not work with the link to the file and the link to the project. Conditional

I am trying to add a link to a project and a file in the same dll in csproj with the BuildingInVsideisualStudio property. But when they are in csproj together, only the file link is selected. If I delete the link to the file, it will take csproj. I tried replacing the order, but no luck. Any ideas why this is not working?

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 taken this path, but there seem to be some reservations . I need to do this conditionally due to my build process, which cannot change. Using a file link makes me lose Go to Definition and Find All References (sorry, but I cannot install ReSharper to solve this problem).

+3
4

, , , - ; msbuild , VS , , , goto-definition R #. - - , .

<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>
+1

, :

  • , $(BuildingInsideVisualStudio) (''). :

    <ItemGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">

  • :

    <ItemGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">


MSDN:

- boolean values. .


UPDATE:

, :

<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'"><!-- In CMD -->
    <ReferenceInclude>MyNamespace.Mine"</ReferenceInclude>
    <ReferenceIncludePath>..\$(OutDir)\MyNamespace.Mine.dll</ReferenceIncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'"><!-- In VS -->
    <ProjectReferenceInclude>..\MyNamespace.Mine.csproj</ProjectReferenceInclude>
    <ProjectReferenceIncludeId>{GUID}</ProjectReferenceIncludeId>
</PropertyGroup> 

, :

<ItemGroup>
    <Reference Include="$(ReferenceInclude)">
        <HintPath>$(ReferenceIncludePath)</HintPath>
    </Reference>
</ItemGroup>
<ItemGroup>
    <ProjectReference Include="$(ProjectReferenceInclude)">
        <Project>$(ProjectReferenceIncludeId)</Project>
        <Name>%(ProjectReferenceInclude.MSBuildProjectName)</Name>
    </ProjectReference>
</ItemGroup>
+6

Visual Studio 2010 2012 Select . , :

<Choose>
  <When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
    <ItemGroup>
      <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
    </ItemGroup>
  </When>
  <Otherwise>
    <ItemGroup>
      <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
    </ItemGroup>
  </Otherwise>
</Choose>
+2

Microsoft's answer sent to this connection question indicates that Visual Studio intentionally ignores the conditions for references to assemblies, the project or not. This is clear; However, the resolution process seems to always prefer file-based links when a project file contains more than one link to the same assembly as a moot point.

In short, you are out of luck if there is no way to tell VS to consider the link to the project, even if the link to the file is present in the same assembly. I do not know how to do this, and I would also be interested to know if this is possible somehow.

0
source

All Articles