从MSBuild发布中排除`.js`文件而不是'.min.js'文件

Blo*_*sie 5 deployment msbuild build msdeploy visual-studio

使用Visual Studio和MSBuild我希望能够排除所有.js文件并包含.min.js我的部署中的所有文件.

我知道这可以使用visual studio中的文件属性来实现,但这不是一个选项,因为文件太多了.


我的PublishProfileVisual Studio项目中有以下内容.一切都很好,除了<ItemGroup>

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <WebPublishMethod>FileSystem</WebPublishMethod>
        <LastUsedBuildConfiguration>Delpoy-Static</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <SiteUrlToLaunchAfterPublish />
        <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
        <ExcludeApp_Data>True</ExcludeApp_Data>
        <publishUrl>\\***\wwwroot\***.com\static</publishUrl>
        <DeleteExistingFiles>False</DeleteExistingFiles>
    </PropertyGroup>
    <!--This does not work, but gives the idea of what I want to achieve-->
    <ItemGroup>
        <Deploy Exclude="**\*.js" Include="**\*.min.js" />
    </ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)

这可以用PublishProfile?如果是这样,怎么样?

Ily*_*kov 10

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <!-- ... -->
  </PropertyGroup>

  <Target Name="BeforeBuild">
    <ItemGroup>
      <Minified Include="**\*.min.js" />
      <Maxified Include="**\*.js" Exclude="@(Minified)" />
      <Content Remove="@(Maxified)" />
    </ItemGroup>
  </Target>
</Project>
Run Code Online (Sandbox Code Playgroud)

编辑:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <!-- ... -->
  </PropertyGroup>

  <ItemGroup>
    <Minified Include="**\*.min.js" />
    <Maxified Include="**\*.js" Exclude="@(Minified)" />
  </ItemGroup>
  <PropertyGroup>
    <ExcludeFoldersFromDeployment>bin</ExcludeFoldersFromDeployment>
    <ExcludeFilesFromDeployment>@(Maxified);Web.config</ExcludeFilesFromDeployment>
  </PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)