如何使用 CLI 在 Azure Devops 中构建 Web 应用程序 MVC5-WEB API 2?

How to build a web app MVC5-WEB API 2 in Azure Devops with CLI?

我想在 Azure 中构建一个 Web 应用程序 (web api 2),但我不想获取 zip,我只想获取一个包含所有必要文件的目录。我不知道执行此操作的命令行。 我不想使用经典的部署 Web 应用程序任务,因为我需要在构建后添加其他文件。在此先感谢您的帮助。

How to build a web app MVC5-WEB API 2 in Azure Devops with CLI?

您可以使用 Visual Studio 构建任务 和 MSBuild 参数:

/p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\" /p:DeployDefaultTarget=WebPublish 

将网络应用程序发布到工件文件夹或您想要的任何其他文件夹。

您也可以直接指定发布配置文件:

/p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:PublishProfile="{publish profile name}";publishUrl="$(build.artifactstagingdirectory)"

使用FileSystem publish方法,发布的文件在一个文件夹中,而不是压缩。

如果您想使用命令行任务而不是 Visual Studio 生成任务,您可以使用相同的 MSBuild 参数调用 MSBuild.exe 来生成此 solution/project:

"<PathForMSBuild.exeOnYourAgent>\MSBuild.exe" "<YourProject/SolutionPath>" /p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\" /p:DeployDefaultTarget=WebPublish

如果你想在构建后添加额外的文件,你可以在 Visual Studio 构建任务之后添加一个任务,或者你可以在你的项目中创建 AfterBuild 目标来添加额外的文件。

希望对您有所帮助。