【问题标题】:Visual Studio 2010 Prof: Solution Explorer not showing files from Import .targetsVisual Studio 2010 教授:解决方案资源管理器不显示来自 Import .targets 的文件
【发布时间】:2011-07-14 09:31:46
【问题描述】:


由于我对单个项目有很多配置,所以我想稍微清理一下 .csproj。
我将所有配置定义移动到带有 Conditional ItemGroup 的单个文件中,并将它们导入到 .csproj 中:

<Import Project="conf/file.targets">

除了一件事,一切似乎都很好,在解决方案资源管理器中我看不到 .targets 中定义的文件,但项目编译没有任何问题。是错误还是正常行为?如何查看从 .targets 导入的文件? (即 SomeFile 和 SomeFile2。)
示例 test.targets:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'TestConfig|x86'">
    <OutputPath>bin\TestConfig\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>

  <ItemGroup Condition=" '$(Configuration)'=='TestConfig' ">
    <Compile Include="SomeFile.cs" />
    <Compile Include="SomeFile2.cs" />
  </ItemGroup>

</Project>

当在 .csproj 中定义时,Solution Explorer 中的所有内容都是可见的。

PS。我在google和stackoverflow中搜索,但没有找到任何有用的信息。

【问题讨论】:

  • 您找到解决方案了吗?
  • @Andy 不,没有解决方案(至少对于 VS 2010),没有尝试过 Visual Studio 版本
  • @Andy 我签入了 VS 2015 Pro,它的行为与 VS2010 完全相同,所以我没有解决方法。

标签: visual-studio-2010 import partial csproj solution-explorer


【解决方案1】:

Visual Studio 对 MSBuild 文件的使用是 MSBuild 功能的子集。

特别是 VS 以它可以理解的方式构建项目文件,很可能有一个有效的 MSBuild 文件不是一个有效的 VS 项目文件。如果你想使用 VS 来管理项目内容,你需要坚持 VS 使用和理解的 MSBuild 子集。

【讨论】:

  • 那么有没有其他方法可以在每 5-10 个条件文件中拥有干净的 managabale .csproj 文件、35-40 个配置?
  • @cichy:我怀疑没有。您可能会更好地查看宏/扩展,以便更轻松地管理配置组(批量参数设置)。
猜你喜欢
  • 2019-04-23
  • 2015-01-10
  • 2012-08-14
  • 1970-01-01
  • 2015-10-25
  • 2015-07-22
  • 1970-01-01
  • 2011-03-27
  • 1970-01-01
相关资源
最近更新 更多