MS Build 是否可以包含所有库项目代码文件而不单独指定它们,并且可以与 Visual Studio 很好地配合使用?
有没有办法通过类库项目的常规 .csproj 文件指示 MS Build 包含所有代码文件(即项目树中的所有 .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>
另一种项目,网站项目,使用一种机制来检测文件修改并重新编译这些文件。编译所有相关内容的概念是我在类库项目中所追求的,但不需要检测更改。
相关的 Visual Studio“问题”:
我意识到 Visual Studio 不太可能遵循我的理想解决方案 - 它一次构建一个文件 - 所以我最终会手动编辑构建文件。 有没有办法让 Visual Studio 与我的理想解决方案完美配合?
Is there a way to instruct MS Build through the regular .csproj file of a class library project to include all code files (i.e. all .cs files in the project tree, sub-folders included) without listing them individually?
The closest solution I'm able to find is Using Wildcards to Specify Items.
This is an example of how Visual studio builds the instruction on a file-by-file basis in my class library project:
<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>
A different kind of project, Website projects, use a mechanism whereby file modifications are detected and those files recompiled. The concept of compiling everything relevant is what I'm going for with a class library project but without the need for detection of changes.
The related Visual Studio "issue":
I realize my ideal solution isn't likely adhered to by Visual Studio - which builds out the build file one file at a time - so I would end up manually editing the build file.
Is there a way to make Visual Studio play nicely with my ideal solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试包含一个外部 MSBuild 文件,其中包含每个文件:
文件: IncludeEverything.proj
更改您的 csproj,以导入其他文件:
通过使用此解决方案,VS 是否包含 csproj 中的文件并不重要...最后,一切都将包括在内。
这使得该解决方案易于在其他项目中重用。
Try including an external MSBuild file, that includes every file:
File: IncludeEverything.proj
Change your csproj, to import the other:
By using this solution, it does not matter whether VS includes files in csproj or not... at the end, everything will be included.
This makes this solution easy to reuse in other projects.