我正在使用 AjaxMin 来缩小我的 .js 和 .css 文件,这是在我的 Release.pubxml 文件中配置的,它工作正常,因为当我导航到 Release/Package/PackageTemp 文件夹时,.js 和 .css 已正确缩小。
但是,当我导航到实际的 Package .zip 文件时,.js 和 .css 文件没有被缩小,它们只是原始文件。我假设我的 PackageTemp 中的文件没有替换 Package 部署文件,我不确定如何从我的 .pubxml 文件中实现这一点。我的 .pubxml 文件目前看起来是这样的:
<?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>
谢谢