2016-01-14 92 views
0

部署到Azure雲服務時是否可以包含額外文件(不包括在ASP.NET/WebRole項目中)?這個項目是一個單頁面應用程序,我需要包含〜500 kb的靜態文件(主要是JavaScript和CSS);在這種情況下使用CDN聽起來有點像矯枉過正。Azure WebRole:通過VisualStudio部署時包含靜態資產

將標準ASP.NET部署到遠程IIS時,我通過簡單地使用CustomCollectFiles擴展發佈配置文件設置(pubxml)來包含這些文件。

我不知道但是如何部署到雲服務時

回答

0

默認CustomCollectFiles不會爲你工作,但與改變你的.csproj的一點點位可以支持這個

包括文件

Azure web role deploy does not copy non-project files

 
<Target Name="CustomCollectFiles"> 
    <ItemGroup> 
     <_DistFiles Include="dist\**\*" /> 
     <FilesForPackagingFromProject Include="%(_DistFiles.Identity)"> 
     <DestinationRelativePath>dist\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath> 
     </FilesForPackagingFromProject> 
     <_SrcFiles Include="src\**\*" /> 
     <FilesForPackagingFromProject Include="%(_SrcFiles.Identity)"> 
     <DestinationRelativePath>src\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath> 
     </FilesForPackagingFromProject> 
    </ItemGroup> 
    </Target> 
    <PropertyGroup> 
    <TypeScriptModuleKind>AMD</TypeScriptModuleKind> 
    <CopyAllFilesToSingleFolderForPackageDependsOn> 
     CustomCollectFiles; 
     $(CopyAllFilesToSingleFolderForPackageDependsOn); 
    </CopyAllFilesToSingleFolderForPackageDependsOn> 
    <CopyAllFilesToSingleFolderForMsdeployDependsOn> 
     CustomCollectFiles; 
     $(CopyAllFilesToSingleFolderForPackageDependsOn); 
    </CopyAllFilesToSingleFolderForMsdeployDependsOn> 
    </PropertyGroup> 
. 
. 
. 
    <Target Name="AfterBuild" DependsOnTargets="CustomCollectFiles"> 
    <Copy SourceFiles="@(_DistFiles)" DestinationFolder="dist" /> 
    </Target> 

另一種選擇可能是包括那些文件鏈接的文件/文件夾如果這應該工作。