0

I have a web application in Visual Studio 2012. I publish this website to IIS using publish profiles (.pubxml).

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <MSDeployServiceURL>server</MSDeployServiceURL>
    <DeployIisAppPath>site</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <UserName>domain\username</UserName>
  </PropertyGroup>
  <ItemGroup>
    <MSDeployParameterValue Include="MyParam">
      <ParameterValue>MyValue</ParameterValue>
    </MSDeployParameterValue>
    ...
  </ItemGroup>
</Project>

Beside I setup a CI to build a package with msbuild and then use it to publish to the different environnement using msdeploy. Both in 2 separates steps, so I can reuse the same package multiple times. To do this I need to use a SetParameters.xml with a different syntax than the publish profil used by VS.

<?xml version="1.0" encoding="utf-8"?>
<parameters>
  <setParameter name="IIS Web Application Name" value="site" />
  <setParameter name="MyParam" value="MyValue" />
  ...
</parameters>

Is there a way to share the parameters configuration in a single file so I can maintain only one file ? I see this answers from 2014 but I can't managed to make it works.

Community
  • 1
  • 1
Rom1
  • 1
  • 1

1 Answers1

0

I've researched this and can't find a way to override the SetParameters file when publish via VisualStudio. It doesn't look like the MSBuild tasks support this.

The best alternative I can offer is to use the commandline instead of right click publish. You can create the MSDeploy package by calling the Package target:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild /t:Package /p:PublishProfile=<profile-name>

And then deploy using MSDeploy.exe:

"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package=WebApplication7.zip -dest:manifest=WebApplication7.DestManifest.xml -setParamFile:SetParameters.custom.xml

The following blog posts has more details:

https://dotnetcatch.com/2016/02/25/the-anatomy-of-a-webdeploy-package/

chief7
  • 14,263
  • 14
  • 47
  • 80
  • Thank you for your answer. This is the way I deploy my packages with the CI. My question is to find a smart way to merge this solution with the clic once publish integrated in VS to allow both deployments with less configuration files. – Rom1 Apr 12 '16 at 12:14