排除`.js`文件,但不是'.min.js'MSBuild中的文件发布 [英] Exclude `.js` files but not '.min.js' files from MSBuild publish
问题描述
使用Visual Studio和MSBuild的,我想可以排除所有的.js
文件,包括所有的 .min.js
在我的部署文件。
我知道这是可以使用Visual Studio中的文件属性来实现,但因为有太多太多的文件,这是不是一种选择。
我在我的Visual Studio项目以下 PublishProfile
。一切工作就好除了<&的ItemGroup GT;
<?XML版本=1.0编码=UTF-8&GT?;
<! -
这个文件是由您的Web项目的发布/包过程中使用。您可以自定义这个过程的行为
通过编辑的MSBuild文件。为了了解更多关于此,请访问http://go.microsoft.com/fwlink/?LinkID=208121。
- >
<项目ToolsVersion =4.0的xmlns =http://schemas.microsoft.com/developer/msbuild/2003>
<&的PropertyGroup GT;
< WebPublishMethod>文件系统< / WebPublishMethod>
< LastUsedBuildConfiguration> Delpoy静态< / LastUsedBuildConfiguration>
< LastUsedPlatform>任何CPU< / LastUsedPlatform>
< SiteUrlToLaunchAfterPublish />
&所述; LaunchSiteAfterPublish>真&下; / LaunchSiteAfterPublish>
&所述; ExcludeApp_Data>真&下; / ExcludeApp_Data>
< publishUrl> \\\\ *** \\ wwwroot的\\ *** COM \\静态的LT; / publishUrl>
< DeleteExistingFiles>假LT; / DeleteExistingFiles>
< /&的PropertyGroup GT;
<! - 这是不行的,但给人的什么,我要实现的想法 - >
<&的ItemGroup GT;
<部署排除=** \\ * JS。包括= /&GT** \\ * min.js。
< /&的ItemGroup GT;
< /项目>
可以这样使用实现 PublishProfile
?如果是这样,怎么样?
<项目ToolsVersion =4.0的xmlns =http://schemas.microsoft.com/developer/msbuild / 2003>
<&的PropertyGroup GT;
< WebPublishMethod>文件系统< / WebPublishMethod>
<! - ... - >
< /&的PropertyGroup GT; <目标名称=BeforeBuild>
<&的ItemGroup GT;
<精缩包括=** \\ * min.js。/>
< Maxified包括=** \\ * JS。排除=@(精缩)/>
<内容删除=@(Maxified)/>
< /&的ItemGroup GT;
< /目标>
< /项目>
编辑:
<项目ToolsVersion =4.0的xmlns =http://schemas.microsoft.com/developer/msbuild/2003>
<&的PropertyGroup GT;
< WebPublishMethod>文件系统< / WebPublishMethod>
<! - ... - >
< /&的PropertyGroup GT; <&的ItemGroup GT;
<精缩包括=** \\ * min.js。/>
< Maxified包括=** \\ * JS。排除=@(精缩)/>
< /&的ItemGroup GT;
<&的PropertyGroup GT;
< ExcludeFoldersFromDeployment>箱位LT; / ExcludeFoldersFromDeployment>
< ExcludeFilesFromDeployment> @(Maxified)的Web.config< / ExcludeFilesFromDeployment>
< /&的PropertyGroup GT;
< /项目>
Using Visual Studio and MSBuild I would like to be able to exclude all .js
files and include all .min.js
files in my deployments.
I know this can be achieved using the file properties in visual studio, but this is not an option as there are far too many files.
I have the following PublishProfile
in my Visual Studio project. Everything works just fine apart from the <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>
Can this be achieved using the PublishProfile
? If so, how?
<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>
Edit:
<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>
这篇关于排除`.js`文件,但不是'.min.js'MSBuild中的文件发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!