MsDeploySkipRules in wpp.targets not working with PublishProfiles

六眼飞鱼酱① 提交于 2020-01-13 05:15:07

问题


I am publishing my MVC project with the PublishProfile through visual studio, (through UI, right click project, publish) and ticking the option to clear the destination folder. But I do not want a specific folder "Downloads" to be cleared

I have spent countless hours trying to make this work, I think I have the exact same code as the person explained here but it still deletes the Downloads folder

Also as example in the below I have the ExcludeFromPackageFiles of "favicon" which works if I deselect the deletion of the destination folder (just to show that my wpp targets is in fact running).

Below is my projectname.wpp.targets file

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <!-- this doesnt work -->
  <PropertyGroup>
    <AfterAddIisSettingAndFileContentsToSourceManifest>AddCustomSkipRules</AfterAddIisSettingAndFileContentsToSourceManifest>
  </PropertyGroup>

  <PropertyGroup>
    <UseMsDeployExe>true</UseMsDeployExe>
  </PropertyGroup>

  <Target Name="AddCustomSkipRules">
    <Message Text="Adding Custom Skip Rules" />
    <ItemGroup>
      <MsDeploySkipRules Include="SkipErrorLogFolder1">
        <SkipAction>Delete</SkipAction>
        <ObjectName>filePath</ObjectName>
        <AbsolutePath>ErrorLog</AbsolutePath>
      </MsDeploySkipRules>
    </ItemGroup>
  </Target>

  <!-- this works! -->
  <ItemGroup>
    <ExcludeFromPackageFiles Include="favicon.ico">
      <FromTarget>ContactManager.Mvc.wpp.targets</FromTarget>
    </ExcludeFromPackageFiles>
  </ItemGroup>

</Project>

Any Ideas?


回答1:


(1) The AbsolutePath value in your example is copy/pasted from my skip rule example. You need to change that value to the path of your Downloads folder.

  <Target Name="AddCustomSkipRules">
    <Message Text="Adding Custom Skip Rules" />
    <ItemGroup>
      <MsDeploySkipRules Include="SkipDownloadsFolder">
        <SkipAction>Delete</SkipAction>
        <ObjectName>filePath</ObjectName>
        <AbsolutePath>Downloads</AbsolutePath>
      </MsDeploySkipRules>
    </ItemGroup>
  </Target>

(2) You cannot use a custom skip rule when publishing from within Visual Studio. You must publish using MSBuild from a command prompt. The nature of my question was about combining the convenience of the publishing profile managed within VS, with the utility of a custom skip rule (which requires the command line), because as of VS 2012 Update 3, the limitation of the command line has not been lifted.

My MSBuild command looks like this:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe My.Website.sln /p:Configuration=Release;DeployOnBuild=true;PublishProfile="Test Server - Web Deploy"

If I attempt to publish from within VS 2012, I get the following error, even though "-verb:sync" is clearly visible in the output:

2>Start Web Deploy Publish the Application/package to http://my.website.example.com/MSDEPLOYAGENTSERVICE ...
2>C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe 
  -source:manifest='C:\inetpub\wwwroot\My.Website\obj\Release\Package\My.Website.SourceManifest.xml' 
  -dest:auto,ComputerName='http://my.website.example.com/MSDEPLOYAGENTSERVICE',UserName='...',Password="...",IncludeAcls='False',AuthType='NTLM' 
  -verb:sync 
  -disableLink:AppPoolExtension 
  -disableLink:ContentExtension 
  -disableLink:CertificateExtension 
  -skip:skipaction='Delete',objectname='filePath',absolutepath='ErrorLog' 
  -skip:objectname='dirPath',absolutepath='obj\\Release\\Package\\PackageTmp\\App_Data$' 
  -skip:objectname='dirPath',absolutepath='MyWebsite/\\App_Data$' 
  -setParamFile:"C:\inetpub\wwwroot\My.Website\obj\Release\Package\My.Website.Publish.Parameters.xml" 
  -retryAttempts=2 
2>MSDEPLOY(0,0): Error : The verb must be specified by using the -verb argument.
2>MSDEPLOY(0,0): Error count: 1.


来源:https://stackoverflow.com/questions/18226048/msdeployskiprules-in-wpp-targets-not-working-with-publishprofiles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!