Reputation: 21833
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
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
Upvotes: 0
Views: 291
Reputation: 84784
You could do this with two publish profiles. It would involve skipping (with caveats if performing the deployment from within Visual Studio) the appropriate content for each profile.
However, I'd recommend doing a full deploy to your application server and then using the runCommand
provider to execute a batch file.
To do this, you could define the following in your publish profile:
<ItemGroup>
<AfterAddIisSettingAndFileContentsToSourceManifest>
$(AfterAddIisSettingAndFileContentsToSourceManifest);
AddContentDeploymentToSourceManifest;
</AfterAddIisSettingAndFileContentsToSourceManifest>
</ItemGroup>
<Target Name="AddContentDeploymentToSourceManifest">
<ItemGroup>
<MsDeploySourceManifest Include="runCommand">
<Path>$(MSBuildProjectDirectory)\deployContent.bat</Path>
</MsDeploySourceManifest>
</ItemGroup>
</Target>
Then, in 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)$
... which deploys the site from the application server to the content server, skipping anything that does not have one of the predefined list of static content extensions.
(FYI: Don't try to sent arguments to your batch file unless it already exists on the server)
Upvotes: 1