视觉工作室.projitems通配符

发布于 2025-01-20 08:22:57 字数 1824 浏览 0 评论 0原文

我修改了项目文件以包含带有通配符的目录中的所有 cs 文件。(见下文)。

不幸的是,每次我使用 Visual Studio 的解决方案资源管理器修改项目时,它都会删除这些通配符并添加到修改后的文件中。

我不想单独添加每个文件。 文档对此并不清楚。它指出应该支持。有人知道如何实现这一点吗?

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
    <HasSharedItems>true</HasSharedItems>
    <SharedGUID>f4ee43f1-9cbc-42af-85c0-69df3a128976</SharedGUID>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="$(MSBuildThisFileDirectory)**/*.cs" />
  </ItemGroup>
</Project>

删除 1 个文件后(请注意,它现在隐藏了一大堆 .cs 文件):


<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
    <HasSharedItems>true</HasSharedItems>
    <SharedGUID>f4ee43f1-9cbc-42af-85c0-69df3a128976</SharedGUID>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="$(MSBuildThisFileDirectory)Test\Class1.cs" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="$(MSBuildThisFileDirectory)Test\Models\" />
  </ItemGroup>
</Project>

I modified the project file to include all cs files in the directory with a wild card.(see below).

Unfortunately every time I modify the project using visual studio's solution explorer it removes these wildcards and adds to modified files.

I would like to not have to add each file individually. The documentation isn't clear on this. It states that it should be supported. Anyone know how this can be achieved?

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
    <HasSharedItems>true</HasSharedItems>
    <SharedGUID>f4ee43f1-9cbc-42af-85c0-69df3a128976</SharedGUID>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="$(MSBuildThisFileDirectory)**/*.cs" />
  </ItemGroup>
</Project>

After removing 1 file (Note that it now hides a whole bunch of .cs files):


<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
    <HasSharedItems>true</HasSharedItems>
    <SharedGUID>f4ee43f1-9cbc-42af-85c0-69df3a128976</SharedGUID>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="$(MSBuildThisFileDirectory)Test\Class1.cs" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="$(MSBuildThisFileDirectory)Test\Models\" />
  </ItemGroup>
</Project>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文