How to use MsBuild MsDeployPublish to target local file system?

后端 未结 3 1736
半阙折子戏
半阙折子戏 2021-01-29 19:38

I\'m trying to replicate the Visual Studio 2010 \"Publish...\" command (applicable to Web Application projects) where I would in the UI choose Publish Method: \"File System\".

3条回答
  •  走了就别回头了
    2021-01-29 20:18

    I gave up trying to get MSBuild to copy deployable web files (and not do anything else but that), so I scripted it in PowerShell and am really happy with the result. Much faster than anything I tried through MSBuild. Here's the gist (literally):

    function copy-deployable-web-files($proj_path, $deploy_dir) {
      # copy files where Build Action = "Content" 
      $proj_dir = split-path -parent $proj_path
      [xml]$xml = get-content $proj_path
      $xml.Project.ItemGroup | % { $_.Content } | % { $_.Include } | ? { $_ } | % {
        $from = "$proj_dir\$_"
        $to = split-path -parent "$deploy_dir\$_"
        if (!(test-path $to)) { md $to }
        cp $from $to
      }
    
      # copy everything in bin
      cp "$proj_dir\bin" $deploy_dir -recurse
    }
    

提交回复
热议问题