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?
If you want to exclude files you can place the files to be excluded in the the ExcludeFromPackageFiles item group. In your case you want to take all .js files and exclude all but those that are
*.min.js
. To do that in your .pubxml file add the following in your .pubxml file .Note: this snippet assumes that your .js files are in a folder named
js
.Edit: