简体   繁体   English

Visual Studio在解决方案资源管理器中不显示来自目标的引用

[英]Visual Studio does not display references from targets in Solution Explorer

Here is a part of my .csproj: 这是我的.csproj的一部分:

<Project DefaultTargets="Build" InitialTargets="MyTarget" xmlns="...">
<Target Name="MyTarget" DependsOnTargets="Include_Ver1;Include_Ver2"/>

 <Target Name="Include_Ver1" Condition="...">
    <ItemGroup>
      <COMReference Include="Ref">      
         1st_Version
      </COMReference>
    </ItemGroup>
  </Target>

 <Target Name="Include_Ver2" Condition="...">
    <ItemGroup>
      <COMReference Include="Ref">      
         2nd_Version
      </COMReference>
    </ItemGroup>
  </Target>

I can use library functions and project builds correctly, but reference does not appear in "References" block inside visual studio solution explorer. 我可以正确使用库函数和项目构建,但是参考没有出现在Visual Studio解决方案资源管理器的“参考”块中。 How can I force Intellisense parse references in Targets? 如何在目标中强制Intellisense解析引用?

Try with different References and below hintpath ,specific version node elements.Make sure the *.csproj is not write only under any Version control system like SVN etc. 尝试使用不同的References并在hintpath下方,特定版本的节点元素下进行操作。确保* .csproj不能仅在诸如SVN等任何版本控制系统下写入。

 <ItemGroup>
    <Reference Include="Microsoft.CSharp" />
        <Reference Include="Microsoft.Owin, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
          <SpecificVersion>False</SpecificVersion>
          <HintPath>..\..\Microsoft.Owin.dll</HintPath>
        </Reference>
    </ItemGroup>

VS doesn't display them because the solution explorer basically shows what it gets after parsing the project file. VS不会显示它们,因为解决方案资源管理器基本上会在解析项目文件后显示其内容。 Parsing != executing, so the reference added in a target is not seen as it never executed - which makes sense, VS cannot guess if the target will even be executed or not and it cannot just start executing random builds to figure out if the reference will be added. 解析!=正在执行,因此不会将目标中添加的引用视为从未执行过-这很有意义,VS无法猜测该目标是否将被执行,并且它无法开始执行随机构建以找出该引用是否将被添加。

Do you really need a target? 您真的需要一个目标吗? ItemGroups can have conditions too, maybe this is sufficient for you? ItemGroups也可以有条件,也许这足以满足您的要求?

<ItemGroup Condition="...">
  <COMReference Include="Ref">      
     1st_Version
  </COMReference>
</ItemGroup>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM