Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AjaxMin不在Azure站点上工作_Azure_Asp.net Mvc 4_Ajaxmin - Fatal编程技术网

AjaxMin不在Azure站点上工作

AjaxMin不在Azure站点上工作,azure,asp.net-mvc-4,ajaxmin,Azure,Asp.net Mvc 4,Ajaxmin,我正在使用微软的AjaxMin缩小我的网站上的javascript,该网站由Azure托管。我使用BuildTask在运行时自动缩小javascript。此生成任务在.csproj文件中指定 该过程正在我的本地环境中运行,但是,当我部署到Azure站点时,它不起作用。当我尝试引用缩小版的.js文件时,azure站点抛出404:file not found错误 是否可以在Azure站点上使用生成任务?我有什么遗漏吗?我已经确保没有像本()教程所建议的那样在源代码管理中包含.min.js文件,但我想

我正在使用微软的AjaxMin缩小我的网站上的javascript,该网站由Azure托管。我使用BuildTask在运行时自动缩小javascript。此生成任务在.csproj文件中指定

该过程正在我的本地环境中运行,但是,当我部署到Azure站点时,它不起作用。当我尝试引用缩小版的.js文件时,azure站点抛出404:file not found错误

是否可以在Azure站点上使用生成任务?我有什么遗漏吗?我已经确保没有像本()教程所建议的那样在源代码管理中包含.min.js文件,但我想知道是否有特定于Azure的内容需要设置


谢谢

生成项目时,生成任务将在Visual Studio中运行。您需要确保缩小的文件也被部署到Azure

我猜可能是因为项目是在构建时生成的,所以它不是项目本身的一部分,部署步骤会忽略这一点


请检查正在使用的部署系统是否包括所有脚本文件,而不仅仅是项目本身中的脚本文件。

我在项目中已使其正常工作。我会告诉你我是怎么做到的,尽管这可能不是最简单或最直接的方法

在开始之前,可以检查Azure部署包中是否包含您的缩小文件,而无需实际部署,这会很有帮助。这很容易做到。
.cspkg
文件实际上是一个zip格式的文件,因此您可以使用任何zip archiver打开它。(我喜欢使用7Zip,因为右键单击->打开存档命令不需要重命名文件,但可以使用Windows资源管理器、WinRAR等)在
.cspkg
中,您将看到另一个扩展名为
.cssx
的大文件。那也是一个zip文件。在
.cssx
中,您将找到一个
站点root
文件夹,其中包含您正在部署的每个网站的子目录,其中将包含所有实际的网站文件。因此,您可以在那里查看哪些文件正在部署到Azure

首先,尝试编辑web项目的项目文件(包含所有Javascript/CSS文件的项目文件)。您可以使用记事本,或者在Visual Studio中右键单击项目,选择“卸载项目”,然后再次右键单击并选择“编辑”。在项目文件中,插入如下节:

<ItemGroup>
    <!-- Copy over all the minified CSS & JS to the output directory-->
    <Content Include="**\*.min.css" />
    <Content Include="**\*.min.js" />
</ItemGroup>
<Target Name="PrepWebApp" Condition="$(Configuration)=='Release'" AfterTargets="AfterBuild">
如果这仍然不起作用,并且您的Web角色中有多个站点和/或虚拟应用程序,则可能不是所有站点都在运行打包步骤。因此,当您将项目打包以部署到Azure时,它可能仍然没有运行缩小步骤(以及web.config转换和其他一些操作)。如果是这种情况,请查看解决方法

万一那篇博文消失了,我会把最相关的部分复制到这里。您可以将其放入web角色的.ccproj文件中(更改适当的位以匹配您的项目结构):


清洁辅助场所;
出版第二网站;
$(CoreBuildDependsOn)
azure.publish\

感谢您的回复。我不确定是否要在项目中包含.min.js文件。据微软称:“如果在项目中包含缩小的文件,并且使用源代码管理,则会遇到问题。当文件从源代码管理检出时,将使用其只读属性集检出这些文件。如果您尝试进行生成,Microsoft Ajax Minifier在尝试写入只读文件时将生成错误。“Azure似乎应该在每次生成后创建文件,而不是从我的本地环境签入文件。”
<PropertyGroup>
  <!-- Inject the publication of "secondary" sites into the Windows Azure build/project packaging process. -->
  <CoreBuildDependsOn>
    CleanSecondarySites;
    PublishSecondarySites;
    $(CoreBuildDependsOn)
  </CoreBuildDependsOn>
  <!-- This is the directory within the web application project directory to which the project will be "published" for later packaging by the Azure project. -->
  <SecondarySitePublishDir>azure.publish\</SecondarySitePublishDir>
</PropertyGroup>
<!-- These SecondarySite items represent the collection of sites (other than the web application associated with the role) that need special packaging. -->
<ItemGroup>
  <SecondarySite Include="..\WebApplication1\WebApplication1.csproj" />
  <SecondarySite Include="..\WebApplication2\WebApplication2.csproj" />
</ItemGroup>
<Target Name="CleanSecondarySites">
  <RemoveDir Directories="%(SecondarySite.RootDir)%(Directory)$(SecondarySitePublishDir)" />
</Target>
<Target Name="PublishSecondarySites" Condition="'$(PackageForComputeEmulator)' == 'true'
                      Or '$(IsExecutingPublishTarget)' == 'true' ">
  <!--
    Execute the Build (and more importantly the _WPPCopyWebApplication) target to "publish" each secondary web application project.

    Note the setting of the WebProjectOutputDir property; this is where the project will be published to be later picked up by CSPack.
  -->
  <MSBuild Projects="%(SecondarySite.Identity)" Targets="Build;_WPPCopyWebApplication" Properties="Configuration=$(Configuration);Platform=$(Platform);WebProjectOutputDir=$(SecondarySitePublishDir)" />