使用VS Code发布Web部署 [英] Publish Web Deploy using VS Code
问题描述
在Visual Studio中,我使用发布网站"功能进行一些web.config转换,然后将WebAPI项目发布到我们的服务器.发布是使用Web Deploy完成的.
In Visual Studio, I use the "publish web" feature to do some web.config transforms, and publish a WebAPI project to our server. The publishing is done using Web Deploy.
现在我正在使用Visual Studio Code,我已经失去了该工具.但是,我想继续使用Web Deploy发布项目. 是否可以通过某种方式编写将发布我的项目的VSCode任务?
Now that I'm using Visual Studio Code, I've lost that tooling. But, I'd like to continue publishing the project using Web Deploy. Is there some way to write a VSCode task that will publish my project?
Visual Studio Publish使用[target] .pubxml文件.我有"staging.pubxml"和"production.xml".这些看起来像MSBuild文件.因此,也许只是从Code执行msbuild任务的问题.不过,不知道从哪里开始.
Visual Studio Publish uses a [target].pubxml file. I have "staging.pubxml" and "production.xml". These look like MSBuild files. So, maybe it's just a matter of executing an msbuild task from Code. Not sure where to start with that, though.
另一个想法是,我可以开始使用Web Deploy命令行工具.我从来没有用过,而且似乎第一个想法会更好.
Another thought is that I could kick off a Web Deploy command line tool. I've never used that, and it seems like the first idea would be better.
推荐答案
假设您现在正在使用最新的vscode(1.7.x).您可以使用Visual Studio Code的任务运行器.
Assuming you are using the latest vscode now (1.7.x). You can use Visual Studio Code's Task Runner.
首先,您需要按<F1>
并输入task
来配置任务运行器.选择任务:配置任务运行器.
First, you would need to configure the task runner by pressing <F1>
and enter task
. Select Tasks: Configure Task Runner.
vscode将使用以下内容创建一个新文件tasks.json
.
A new file tasks.json
would be created by vscode with following content.
{
// 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
数组中添加新任务:
Second, now you would need to add the new publish task. With the answer given by @Rolo, you can add a new task in the tasks
array:
{
"taskName": "publish",
// Always show errors from builds.
"showOutput": "always",
"args": [
"/p:DeployOnBuild=true",
"/p:PublishProfile=Test"
]
}
第三,一旦tasks.json
完成.您可以通过按Ctrl
+ P
(在Mac上为Cmd
+ P
)并键入task publish
来使用publish
任务.
Third, once the tasks.json
is completed. You can use the publish
task by pressing Ctrl
+P
(or Cmd
+P
on Mac), and type task publish
.
这篇关于使用VS Code发布Web部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!