VSTS 中 NETCore2 WebJob 的构建定义
Build definition for NETCore2 WebJob in VSTS
我正在 Visual Studio Team Services 中为 WebApp 设置构建定义,包括一些 WebJobs,所有这些都在 .NET Core 2 中。
设置的任务是:
- NuGet 4.4.1:NuGet 工具安装程序
- NuGet 恢复
- NPM 安装
- Gulp
- 构建解决方案(包含 .sln 中的所有项目,包括
webapp 和 webjob)。
- Azure 应用服务部署:(webapp)
- Azure 应用服务部署:(网络作业)
- 更新数据库 (.dacpac)
- rest/cleanup...
问题 1:使用 .NETCore 2 我无法 link VS2017 中的网络作业到网络应用程序。
问题 2:我似乎找不到将 webjob 部署到 webapp 目标中的子文件夹 /site/wwwroot/app_data/Jobs/Triggered
的方法。
为此,我尝试在 msdeploy 上设置参数(如 -dest:
),但也失败了。
问题三:市场上好像没有专门针对这个的任务。
问题 4:(不是真正的问题,但没关系),我无法通过网络找到任何提示。
生成任务中的 msbuild 参数:
/m /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=false /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\"
然后我有几个压缩项目,然后我可以使用不同的 Azure App Service Deploy 任务单独获取它们。一切都运行成功,但是 webjob 没有发布,因为我似乎无法将它定位到 webapp。
下面是 Azure 应用服务部署输出:
> ##[section]Starting: Azure App Service Deploy: ******devapi webjob
> ============================================================================== Task : Azure App Service Deploy Description : Update Azure
> App Service using Web Deploy / Kudu REST APIs Version : 2.1.14
> Author : Microsoft Corporation Help : [More
> Information](https://aka.ms/azurermwebdeployreadme)
> ============================================================================== 9eda6c4a-a587-4dda-b343-fecd5027a2f8 exists true Got connection
> details for Azure App Service:'******devapi' [command]"C:\Program
> Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:getParameters
> -source:package='D:\a\a\******.Webjob.zip' <output> <parameters>
> <parameter name="IIS Web Application Name" value="Default Web Site" tags="IisApp">
> <parameterEntry kind="ProviderPath" scope="IisApp" match="^D:\a\1\s\src\jobs\******\.Webjob\obj\Release\netcoreapp2\.0\PubTmp\Out\$"
> />
> </parameter> </parameters> [command]"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync
> -source:package='D:\a\a\******.Webjob.zip' -dest:auto,ComputerName='https://******devapi.scm.azurewebsites.net:443/msdeploy.axd?site=******devapi',UserName='********',Password='********',AuthType='Basic' -setParam:name='IIS Web Application Name',value='******devapi' -enableRule:AppOffline -enableRule:DoNotDeleteRule -userAgent:VSTS_someguid Info: Using ID 'xxx' for connections to the remote server. Total changes: 0 (0 added, 0 deleted, 0 updated, 0
> parameters changed, 0 bytes copied) App Service successfully deployed
> at url http://******devapi.azurewebsites.net Successfully updated
> deployment History at
> https://******devapi.scm.azurewebsites.net/deployments/27891522952986583
> ##[section]Finishing: Azure App Service Deploy: ******devapi webjob
请问有人知道如何在 VSTS 中处理 WebJobs 和构建定义吗?
编辑:我已经拆分了构建和发布,以便在成功构建后在发布定义上拾取工件。
所以我在 this guide.
之后找到了我的答案
它的作用是解决我的第一个问题(这也是最有意义的)。
Problem 1: with .NETCore 2 i am unable to link the webjob to the
webapp in VS2017.
这样,网络作业就是 'hooked' 您要发布它的应用程序。本指南中说明的注释。在 webapp .csproj replace/remove $(ProjectDir)$(PublishDir)
中根据您的需要进行设置。
<Target Name="PostpublishScript" AfterTargets="Publish">
<Exec Command="dotnet publish ..\Azure.WebJob.Continous\ -o $(ProjectDir)$(PublishDir)App_Data\Jobs\Continuous\Azure.WebJob.Continous" />
<Exec Command="dotnet publish ..\Azure.WebJob.Triggered\ -o $(ProjectDir)$(PublishDir)App_Data\Jobs\Triggered\Azure.WebJob.Triggered" />
</Target>
我正在 Visual Studio Team Services 中为 WebApp 设置构建定义,包括一些 WebJobs,所有这些都在 .NET Core 2 中。 设置的任务是:
- NuGet 4.4.1:NuGet 工具安装程序
- NuGet 恢复
- NPM 安装
- Gulp
- 构建解决方案(包含 .sln 中的所有项目,包括 webapp 和 webjob)。
- Azure 应用服务部署:(webapp)
- Azure 应用服务部署:(网络作业)
- 更新数据库 (.dacpac)
- rest/cleanup...
问题 1:使用 .NETCore 2 我无法 link VS2017 中的网络作业到网络应用程序。
问题 2:我似乎找不到将 webjob 部署到 webapp 目标中的子文件夹 /site/wwwroot/app_data/Jobs/Triggered
的方法。
为此,我尝试在 msdeploy 上设置参数(如 -dest:
),但也失败了。
问题三:市场上好像没有专门针对这个的任务。
问题 4:(不是真正的问题,但没关系),我无法通过网络找到任何提示。
生成任务中的 msbuild 参数:
/m /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=false /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\"
然后我有几个压缩项目,然后我可以使用不同的 Azure App Service Deploy 任务单独获取它们。一切都运行成功,但是 webjob 没有发布,因为我似乎无法将它定位到 webapp。
下面是 Azure 应用服务部署输出:
> ##[section]Starting: Azure App Service Deploy: ******devapi webjob
> ============================================================================== Task : Azure App Service Deploy Description : Update Azure
> App Service using Web Deploy / Kudu REST APIs Version : 2.1.14
> Author : Microsoft Corporation Help : [More
> Information](https://aka.ms/azurermwebdeployreadme)
> ============================================================================== 9eda6c4a-a587-4dda-b343-fecd5027a2f8 exists true Got connection
> details for Azure App Service:'******devapi' [command]"C:\Program
> Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:getParameters
> -source:package='D:\a\a\******.Webjob.zip' <output> <parameters>
> <parameter name="IIS Web Application Name" value="Default Web Site" tags="IisApp">
> <parameterEntry kind="ProviderPath" scope="IisApp" match="^D:\a\1\s\src\jobs\******\.Webjob\obj\Release\netcoreapp2\.0\PubTmp\Out\$"
> />
> </parameter> </parameters> [command]"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync
> -source:package='D:\a\a\******.Webjob.zip' -dest:auto,ComputerName='https://******devapi.scm.azurewebsites.net:443/msdeploy.axd?site=******devapi',UserName='********',Password='********',AuthType='Basic' -setParam:name='IIS Web Application Name',value='******devapi' -enableRule:AppOffline -enableRule:DoNotDeleteRule -userAgent:VSTS_someguid Info: Using ID 'xxx' for connections to the remote server. Total changes: 0 (0 added, 0 deleted, 0 updated, 0
> parameters changed, 0 bytes copied) App Service successfully deployed
> at url http://******devapi.azurewebsites.net Successfully updated
> deployment History at
> https://******devapi.scm.azurewebsites.net/deployments/27891522952986583
> ##[section]Finishing: Azure App Service Deploy: ******devapi webjob
请问有人知道如何在 VSTS 中处理 WebJobs 和构建定义吗?
编辑:我已经拆分了构建和发布,以便在成功构建后在发布定义上拾取工件。
所以我在 this guide.
之后找到了我的答案它的作用是解决我的第一个问题(这也是最有意义的)。
Problem 1: with .NETCore 2 i am unable to link the webjob to the webapp in VS2017.
这样,网络作业就是 'hooked' 您要发布它的应用程序。本指南中说明的注释。在 webapp .csproj replace/remove $(ProjectDir)$(PublishDir)
中根据您的需要进行设置。
<Target Name="PostpublishScript" AfterTargets="Publish">
<Exec Command="dotnet publish ..\Azure.WebJob.Continous\ -o $(ProjectDir)$(PublishDir)App_Data\Jobs\Continuous\Azure.WebJob.Continous" />
<Exec Command="dotnet publish ..\Azure.WebJob.Triggered\ -o $(ProjectDir)$(PublishDir)App_Data\Jobs\Triggered\Azure.WebJob.Triggered" />
</Target>