gpt4 book ai didi

msbuild - 使用 VS Code 发布 Web 部署

转载 作者:行者123 更新时间:2023-12-03 11:42:12 26 4
gpt4 key购买 nike

在 Visual Studio 中,我使用“发布 Web”功能进行一些 web.config 转换,并将 WebAPI 项目发布到我们的服务器。发布是使用 Web Deploy 完成的。

现在我在使用 Visual Studio Code,我已经失去了那个工具。但是,我想继续使用 Web Deploy 发布项目。 有什么方法可以编写一个 VSCode 任务来发布我的项目吗?

Visual Studio Publish 使用 [target].pubxml 文件。我有“staging.pubxml”和“production.xml”。这些看起来像 MSBuild 文件。因此,也许这只是从 Code 执行 msbuild 任务的问题。不过,不确定从哪里开始。

另一个想法是我可以启动 Web Deploy 命令行工具。我从来没有用过,似乎第一个想法会更好。

最佳答案

假设您现在使用的是最新的 vscode (1.7.x)。您可以使用 Visual Studio Code 的 Task Runner。

首先,您需要按 <F1> 来配置任务运行器。然后输入 task .选择任务:配置任务运行器。

一个新文件 tasks.json将由具有以下内容的 vscode 创建。

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "msbuild",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true"
],
"taskSelector": "/t:",
"showOutput": "silent",
"tasks": [
{
"taskName": "build",
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
}
]
}

其次,现在您需要添加新的发布任务。使用@Rolo 给出的答案,您可以在 tasks 中添加一个新任务大批:
    {
"taskName": "publish",
// Always show errors from builds.
"showOutput": "always",
"args": [
"/p:DeployOnBuild=true",
"/p:PublishProfile=Test"
]
}

三、曾经的 tasks.json完成了。您可以使用 publishCtrl 完成任务+ P (或 Cmd + P 在 Mac 上),然后输入 task publish .

关于msbuild - 使用 VS Code 发布 Web 部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29994482/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com