Visual studio 2010 MS Build是否可以包含所有库项目代码文件而不单独指定它们,并与Visual Studio配合使用?

Visual studio 2010 MS Build是否可以包含所有库项目代码文件而不单独指定它们,并与Visual Studio配合使用?,visual-studio-2010,c#-4.0,msbuild,csproj,Visual Studio 2010,C# 4.0,Msbuild,Csproj,是否有方法指示MS Build通过类库项目的常规.csproj文件包含所有代码文件(即项目树中的所有.cs文件,包括子文件夹),而不单独列出它们 我能找到的最接近的解决方案是 这是Visual studio如何在我的类库项目中逐个文件构建指令的示例: <ItemGroup> <Compile Include="Controllers\HomeController.cs" /> <Compile Include="Controllers\Parti

是否有方法指示MS Build通过类库项目的常规.csproj文件包含所有代码文件(即项目树中的所有.cs文件,包括子文件夹),而不单独列出它们

我能找到的最接近的解决方案是

这是Visual studio如何在我的类库项目中逐个文件构建指令的示例:

  <ItemGroup>
    <Compile Include="Controllers\HomeController.cs" />
    <Compile Include="Controllers\ParticipantController.cs" />
    <Compile Include="Global.asax.cs">
      <DependentUpon>Global.asax</DependentUpon>
    </Compile>
    <Compile Include="Models\ParticipantModel.cs" />
    <Compile Include="Models\UserModel.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Utility.cs" />
  </ItemGroup>

Global.asax
另一种不同类型的项目,即网站项目,使用一种机制来检测文件修改并重新编译这些文件。编译所有相关内容的概念是我在类库项目中想要的,但不需要检测更改

相关的Visual Studio“问题”:
我意识到我的理想解决方案不太可能被VisualStudio所遵循——它一次生成一个文件——因此我最终会手动编辑生成文件。
有没有办法让VisualStudio与我的理想解决方案配合得很好

尝试包含一个外部MSBuild文件,该文件包含所有文件:

文件:IncludeEverything.proj

  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="BeforeBuild">
      <ItemGroup>
        <Compile Remove="@(Compile)" />
        <Compile Include="*.cs;.\**\*.cs" />
      </ItemGroup>
    </Target>
  </Project>

更改您的csproj,以导入另一个:

  ...
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Import Project="IncludeEverything.proj" />
  ...
。。。
...
通过使用此解决方案,无论VS是否在csproj中包含文件。。。最后,一切都将包括在内

这使得该解决方案易于在其他项目中重用