msbuildvisual-studio-2015web-deploymentmsdeploypubxml

Ajax Minifier to Deploy Package .zip


I'm using AjaxMin to minify my .js and .css files this is configured within my Release.pubxml file and it works fine as when I navigate to the Release/Package/PackageTemp folder the .js and .css have been minified correctly.

However when I navigate to the actual Package .zip file the .js and .css files have not been minified they are just the original files. I assume that the files in my PackageTemp are not replacing the Package deploy files and I'm not sure how to achieve this from within my .pubxml file. My .pubxml file currently looks this this:

<?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>Package</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>True</ExcludeApp_Data>
    <DesktopBuildPackageLocation>C:\Documents\TestDeploy</DesktopBuildPackageLocation>
    <PackageAsSingleFile>true</PackageAsSingleFile>
    <DeployIisAppPath />
    <PublishDatabaseSettings>
      <Objects xmlns="" />
    </PublishDatabaseSettings>
  </PropertyGroup>

  <Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\AjaxMin.targets" />
  <PropertyGroup>
    <OnAfterPackageUsingManifest>
      $(OnAfterPackageUsingManifest); Minify;
    </OnAfterPackageUsingManifest>
  </PropertyGroup>

  <Target Name="Minify" AfterTargets="CopyAllFilesToSingleFolderForPackage">
    <ItemGroup>
      <JS Include="$(_PackageTempDir)\**\*.js" Exclude="$(_PackageTempDir)\**\*.min.js;" />
      <CSS Include="$(_PackageTempDir)\**\*.css" Exclude="$(_PackageTempDir)\**\*.min.css" />
    </ItemGroup>

    <Message Text="**************MINIFYING**************" Importance="high"></Message>
    <AjaxMin JsSourceFiles="@(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".js" CssSourceFiles="@(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".css" />
  </Target>

  <PropertyGroup>
    <ExcludeFoldersFromDeployment>bin</ExcludeFoldersFromDeployment>
  </PropertyGroup>

</Project>
Please could someone shed some light on how to replace the files in my deploy .zip file with the PackageTemp Files via my .pubxml file

Thanks


Solution

  • My error i just noticed i was using the OnAfterPackageUsingManifest option. For anyone that also faces this issue try using the OnBeforePackageUsingManifest option instead.