在 Visual Studio 2019 .NET Web 应用程序中从构建操作中排除文件夹

Excluding folder from Build operation in Visual Studio 2019 .NET Web Application

我创建了 ASP.Net 网络应用程序并在网络应用程序中添加了 Angular 11 个应用程序作为名为“AngularApp”的子文件夹。我在“.csproj”中添加了以下设置,以在 ASP.Net Web 应用程序构建过程中排除“AngularApp”文件夹。但是即使在构建过程中排除了该文件夹后,我仍收到与“node_modules”相关的构建错误。你能帮我解决这个问题吗?

<ItemGroup>
  <Compile Remove="AngularApp\**" />
  <Content Remove="AngularApp\**" />
  <EmbeddedResource Remove="AngularApp\**" />
  <None Remove="AngularApp\**" />
  <Content Include="AngularApp\dist\prod\**\*" />
  <Content Update="AngularApp\dist\prod\**\*;appsettings.json;web.config">
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
  </Content>
</ItemGroup>

您可以在您的 csproj 文件中使用它:

<ItemGroup>
    <!-- display folder in solution explorer -->
    <Content Include="AngularApp\**"/>    

    <!-- ignore the folder while building -->
    <Compile Include="AngularApp\**" Exclude="AngularApp\**" />
</ItemGroup>