私のプロジェクトではこれが適切に機能しています。私がそれをどのように行ったかをお話ししますが、これは最も単純または最も簡単な方法ではないかもしれません。
始める前に、実際にデプロイせずに、縮小されたファイルがAzureデプロイメントパッケージに含まれているかどうかを確認できると便利です。とても簡単です。この.cspkg
ファイルは実際にはzip形式のファイルであるため、任意のzipアーカイバで開くことができます。(右クリック-> [アーカイブを開く]コマンドではファイルの名前を変更する必要がないため、7Zipを使用するのが好きですが、Windows Explorer、WinRARなどを使用できます。)内部には、次の.cspkg
ような別の大きなファイルが表示されます。.cssx
拡張機能。これもzipファイルです。中には、展開している各Webサイトのサブディレクトリが含ま.cssx
れるフォルダがあります。このsitesroot
サブディレクトリには、実際のすべてのWebサイトファイルが含まれています。そのため、そこをざっと見て、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>
次に、プロジェクトをリロードして再パッケージ化し、ファイルがファイルに含まれているかどうかを確認し.cspkg
ます。もしそうなら、あなたは完了です。
そうでない場合は、他に確認すべきことがいくつかあります。ミニファイは、適切なビルド段階で実行されていない可能性があります。私の縮小ターゲットは次のようになります。
<Target Name="PrepWebApp" Condition="$(Configuration)=='Release'" AfterTargets="AfterBuild">
それでも機能せず、Webロールに複数のサイトや仮想アプリケーションが含まれている場合は、すべてのサイトでパッケージ化手順が実行されていない可能性があります。そのため、Azureにデプロイするためにプロジェクトをパッケージ化する場合、プロジェクトはまだミニファイステップを実行していない可能性があります(web.config変換などと一緒に)。その場合は、このブログ投稿で修正方法を確認してください。
そのブログ投稿がなくなった場合に備えて、ここに最も関連性の高いビットをコピーします。これをWebロールの.ccprojファイルに入れます(プロジェクト構造に一致するように適切なビットを変更します)。
<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)" />