Web部署-使用相对路径进行本地文件系统部署 [英] Web Deploy - Using Relative Paths for local file system deployment

查看:326
本文介绍了Web部署-使用相对路径进行本地文件系统部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Web Deploy运行自定义部署设置.

I am wanting to use Web Deploy to run a custom deployment setup.

由于我希望在许多不同的环境(团队成员本地计算机,4个不同的构建服务器)上运行时都能正常工作,所以我想部署到相对的本地路径.

As I am wanting to have this work fine when running on many different environments (team members local machines, 4 different builds servers) I want to deploy to a local path that is relative.

我想做的是:

  • 部署到本地相对路径
  • 在构建之后执行神奇的事情……

但是,当我输入要部署为的本地文件路径时:".. \ Deploy_Production"

However when i enter the local file path to deploy to as: "..\Deploy_Production"

网络部署对此抱怨:

2>Connecting to ..\Deploy_Live...
2>Unable to create the Web site '../Deploy_Live'.  The URL http://:0 is invalid.

就好像Web部署认为相对文件路径是网站URL.相反,使用".. \"对我的事业没有帮助.

Its as if Web deploy thinks that the relative file path is a website URL. Using "..\" instead doesn't help my cause.

如何使WebDeploy部署到本地相对路径?

How do you get WebDeploy to deploy to a local relative path?

我试图在构建之前使用ConvertToAbsolutePath任务,但无济于事:

I have tried to use a ConvertToAbsolutePath task before build, to no avail:

  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <SiteUrlToLaunchAfterPublish>http://mywebsite.com</SiteUrlToLaunchAfterPublish>
    <publishUrl>..\Deploy_Production</publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
  </PropertyGroup>

  <Target Name="BeforeBuild">
    <ConvertToAbsolutePath Paths="$(publishUrl)">
      <Output TaskParameter="AbsolutePaths" PropertyName="publishUrl" />
    </ConvertToAbsolutePath>
  </Target>

修改2: 上面的方法有效,但仅在运行命令行时针对 Solution 文件而不是 project 文件

Edit 2: The above works, but only when running commandline builds against the Solution file not a project file

推荐答案

我们这里有一个错误,当使用文件系统发布时,您必须提供完整的路径.实际上,我们在本周初发现了此错误.它将在我们的下一个更新中修复.在这种情况下,当传递相对路径时,它会错误地认为它是IIS路径.

We have a bug here, when publishing using File system you have to provide a full path. We actually found this bug earlier this week. It will be fixed in our next update. In this case when the relative path is passed it incorrectly thinks that its an IIS path.

作为一种解决方法,您可以编辑.pubxml以使publishUrl成为完整路径.幸运的是,您可以使用MSBuild属性,以便在团队方案中使用.这是您应该执行的操作,编辑.pubxml文件,并将publishUrl的值更新为以下值.

As a workaround you can edit the .pubxml to make the publishUrl a fullpath. Fortunately you can use an MSBuild property so that this works in team scenarios. Here is what you should do, edit your .pubxml file and update the value of publishUrl to be the following.

<publishUrl>$(MSBuildThisFileDirectory)..\..\..\Deploy_Production</publishUrl>

此路径将相对于.pubxml文件本身.我已经验证了它在命令行以及发布对话框中都可以正常工作.如果您对此有任何疑问,请通知我,但希望该修复程序可以在几个月内发布[当然不能保证:)].

This path will be relative to the .pubxml file itself. I've verified that this works from both the command line as well as the publish dialog. If you have any issues with this let me know, but the fix should hopefully be released in a few months [no guarantees of course :) ].

这篇关于Web部署-使用相对路径进行本地文件系统部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆