<!--
***********************************************************************************************
Microsoft.NET.Sdk.Publish.ZipDeploy.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.
***********************************************************************************************
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask TaskName="ZipDeploy" AssemblyFile="$(_PublishTaskAssemblyFullPath)" />
  <UsingTask TaskName="CreateZipFile" AssemblyFile="$(_PublishTaskAssemblyFullPath)" />
  <UsingTask TaskName="GetPassword" AssemblyFile="$(_PublishTaskAssemblyFullPath)" />

  <PropertyGroup>
    <_DotNetPublishFiles>
      ZipDeploy;
    </_DotNetPublishFiles>
  </PropertyGroup>

  <!--
  ***********************************************************************************************
  TARGET : CreateZipFile
  ***********************************************************************************************
 -->

  <Target Name="CreateZipFile">
    <MakeDir Directories="$(PublishIntermediateTempPath)" 
      Condition="!Exists('$(PublishIntermediateTempPath)')" />

    <CreateZipFile
      FolderToZip="$(PublishIntermediateOutputPath)"
      ProjectName="$(MSBuildProjectName)"
      PublishIntermediateTempPath="$(PublishIntermediateTempPath)">
      <Output TaskParameter="CreatedZipPath" PropertyName="ZippedPublishContentsPath"/>
    </CreateZipFile>
  </Target>

  <!--
  ***********************************************************************************************
  TARGET : ZipDeploy
  ***********************************************************************************************
 -->

  <Target Name="ZipDeploy" DependsOnTargets="CreateZipFile">
    <PropertyGroup>
      <ZipDeployUserAgent Condition="'$(VisualStudioVersion)' == ''">WebSdk</ZipDeployUserAgent>
      <ZipDeployUserAgent Condition="'$(VisualStudioVersion)' != ''">WebSdk_VisualStudio_$(VisualStudioVersion)</ZipDeployUserAgent>
    </PropertyGroup>

    <GetPassword
       EncryptedPassword ="$(EncryptedPassword)"
       Condition="'$(Password)' == '' And '$(IsGetPasswordEnabled)' == 'true'">
      <Output TaskParameter="ClearPassword" PropertyName="Password"/>
    </GetPassword>

    <ZipDeploy
      ZipToPublishPath="$(ZippedPublishContentsPath)"
      SiteName="$(DeployIisAppPath)"
      PublishUrl="$(PublishUrl)"
      DestinationUsername="$(UserName)"
      DestinationPassword="$(Password)"
      UserAgentVersion="$(ZipDeployUserAgent)"/>
  </Target>

</Project>
