gpt4 book ai didi

visual-studio - 从 MSBuild 发布中排除 `.js` 文件但不排除 '.min.js' 文件

转载 作者:行者123 更新时间:2023-12-04 06:30:30 26 4
gpt4 key购买 nike

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

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

我有以下 PublishProfile在我的 Visual 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>

这可以使用 PublishProfile 来实现吗? ?如果是这样,如何?

最佳答案

<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>

编辑:
<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>

关于visual-studio - 从 MSBuild 发布中排除 `.js` 文件但不排除 '.min.js' 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25525197/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com