0

Given an ASP.NET webapp that is already deployed using WebDeploy to its live server, how can I also deploy a subset of that application to another server?

eg

  • Entire webapp / all files including static files-> web deploy to domain.com
  • Static files only (js,images,css) -> web deploy to static.com

This is for the purpose of creating a separate cookieless site for static content only.

Is it possible with just one publish profile? Or do I need to create two publish profiles?

And is it even possible to create a publish profile that only deploys the static part of the webapp (everything in the ~/Content directory)?

Both target servers are II7.5 running on Windows 2008 64bit

4

1 回答 1

1

您可以使用两个发布配置文件来做到这一点。这将涉及跳过(如果从 Visual Studio 中执行部署,则需要注意)每个配置文件的适当内容。

但是,我建议对您的应用程序服务器进行完整部署,然后使用runCommand提供程序执行批处理文件。

为此,您可以在发布配置文件中定义以下内容:

<ItemGroup>
    <AfterAddIisSettingAndFileContentsToSourceManifest>
        $(AfterAddIisSettingAndFileContentsToSourceManifest);
        AddContentDeploymentToSourceManifest;
    </AfterAddIisSettingAndFileContentsToSourceManifest>
</ItemGroup>

<Target Name="AddContentDeploymentToSourceManifest">
    <ItemGroup>
        <MsDeploySourceManifest Include="runCommand">
            <Path>$(MSBuildProjectDirectory)\deployContent.bat</Path>
        </MsDeploySourceManifest>
    </ItemGroup>
</Target>

然后,在 deployContent.bat 中:

REM Detect MSDeploy location (stolen from VS generated CMD)
if "%MSDeployPath%" == "" (
for /F "usebackq tokens=1,2,*" %%h  in (`reg query "HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy" /s  ^| findstr -i "InstallPath"`) do (
if /I "%%h" == "InstallPath" ( 
if /I "%%i" == "REG_SZ" ( 
if not "%%j" == "" ( 
if "%%~dpj" == "%%j" ( 
set MSDeployPath=%%j
))))))

"%MSDeployPath%mdeploy.exe" -verb:sync ^
    -source:iisApp="application site name" 
    -dest:iisApp="static content site name",computerName=http://contentserver:8192/msdeploy.axd
    -skip:File=^.*(?<!png|jpg|jpeg|css|js)$

...它将站点从应用程序服务器部署到内容服务器,跳过任何没有预定义的静态内容扩展列表之一的内容。

(仅供参考:不要尝试将参数发送到您的批处理文件,除非它已经存在于服务器上

于 2012-10-05T06:53:05.643 回答