【问题标题】:Excluding folder from Build operation in Visual Studio 2019 .NET Web Application从 Visual Studio 2019 .NET Web 应用程序中的构建操作中排除文件夹
【发布时间】:2021-05-18 17:25:55
【问题描述】:

我创建了 ASP.Net Web 应用程序,并在 Web 应用程序中添加了 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>

【问题讨论】:

  • 因为这是一个 Web 应用程序项目(与基于 .NET SDK 的项目相反),除非包含文件,否则会排除文件。除非有其他东西包括它们,否则您的删除不应该是必要的。是否还有另一种相互竞争的 glob 模式?

标签: c# asp.net msbuild visual-studio-2019


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-19
    • 2017-07-31
    相关资源
    最近更新 更多