WebApplication 发布到相对文件系统路径
我正在设置发布到相对路径以进行本地测试(尤其是 xml 配置转换)。每个开发人员都有自己的签出项目路径,我想设置一个与机器/环境无关的发布。
发布对话框不提示其中允许的任何变量或通配符,并且不接受 obj\publish
或 file://./obj/publish
有没有办法发布到相对文件系统路径?
I'm setting up a publish to a relative path for testing locally (especially xml config transformations). Each developer has their own path to the checked out project and I'd like to set up a publish that is machine/environment agnostic.
The publish dialog doesn't hint at any variables or wildcards that are allowed in it and it doesn't accept obj\publish
or file://./obj/publish
Is there a way to publish to a relative filesystem path?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
对于使用 Visual Studio 2012 和新发布配置文件 (
Properties/PublishProfiles/Local.pubxml
) 的用户,您可以在文件本身中使用此语法:请注意,$(MSBuildThisFileDirectory) 属性将解析为Local.pubxml 目录。从那里你应该向上移动到达你需要去的地方。
For those using Visual Studio 2012 and the new publish configuration file (
Properties/PublishProfiles/Local.pubxml
) you can use this syntax in the file itself:Be aware that the $(MSBuildThisFileDirectory) property will resolve to the Local.pubxml directory. From there you should traverse up to get where you need to be.
编辑
对于 Visual Studio 2012,此解决方案将不起作用。你应该看看 michielvoo 在这个问题之后的答案。
原始答案
设置来使用相对路径
经过尝试和尝试,我找到了解决方案:您可以通过在 Publish WebApp 对话框中 ,但您必须使用您正在使用的用户已经存在且可写的路径。这样您就可以在本地文件夹或路径相关文件夹中发布您的 Web 应用程序。
让我知道这是否有帮助。它对我有用。
Edit
For Visual Studio 2012, this solution will not work. You should look at the answer by michielvoo just after this one.
Original answer
After trying and trying I found the solution: you can use a relative path by setting
in the
Publish WebApp
dialog, but you must use a path that is already existent and writable by the user you are using. This way you can publish your web app in a local folder, or a path related folder.Let me know if this helps. It did for me.
在 Visual Studio 2012 中,只有带有正斜杠的常规路径有效:
这从已发布项目的根目录开始。
Just a regular path with forward slashes works in Visual Studio 2012:
This starts at the published project's root directory.
这在 Visual Studio 2013 中对我有用:
请注意,这不会像原始发布者想要的那样发布到 obj\publish,而是按照我的需要发布到系统上的另一个目录(上面的几个文件夹)。如果您愿意,请将其修改为 obj\publish。
This worked for me in Visual Studio 2013:
Please note that this doesn't publish to obj\publish, as the original poster wanted, but to another directory (a few folders up) on my system as I desired. Modify it for obj\publish if you wish.
VS 2015 接受类似的内容,
如果缺少该文件夹,它也会创建该文件夹,因此您的发布设置可以进入源代码管理,但您可以轻松忽略 DeployFiles 文件夹及其内容。
VS 2015 accepts something like
It will also create the folder if it is missing so your publish settings can go into source control but you can easily ignore the DeployFiles folder and its contents.
对于额外的发布后步骤需要使用相对路径调用 msdeploy(MSVS 2015,dnx)的情况,另一种选择是编辑项目文件(不是 pubxml,尽管这也可能有效)并创建一个变量,该变量是相对路径转换为绝对路径。
然后
$(AbsOutDir)
可以根据需要在其他地方使用(例如 msdeploy contentPath)。我认为它不能在对话框中输入。来自“how-can-i-get-msbuild-to-evaluate-and-print-the-full-path-when-given- a-亲戚”。
For the case where an additional post publish step needs to call msdeploy (MSVS 2015, dnx) with a relative path, another alternative is to edit project file (not the pubxml although that may work too) and create a variable that is the conversion of the relative path into an absolute path.
Then
$(AbsOutDir)
can be used elsewhere as needed (such as for msdeploy contentPath). I don't think it can be entered within the dialog.From "how-can-i-get-msbuild-to-evaluate-and-print-the-full-path-when-given-a-relative".