如何为以.Net Core为目标的ASP.Net 5应用程序构建MSDeploy程序包 [英] How to build an MSDeploy package for an ASP.Net 5 app that targets .Net Core

查看:92
本文介绍了如何为以.Net Core为目标的ASP.Net 5应用程序构建MSDeploy程序包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Visual Studio Online配置为将TeamNET Build文档中的本教程中所述的ASPNET 5应用程序连续部署到Azure webapp:

I'm trying to configure Visual Studio Online to continuously deploy my ASPNET 5 application to an Azure webapp as described in this tutorial from the Team Foundation Build docs: https://msdn.microsoft.com/Library/vs/alm/Build/azure/deploy-aspnet5

我已经按照所有步骤进行了,一切都很好.默认情况下,此脚本会部署针对完整.Net 4.5.1 DNX的应用程序构建,因此我决定尝试对其进行修改,以针对.Net Core进行部署.

I have followed all the steps and everything is working great. By default this script deploys a build of my app that targets the full .Net 4.5.1 DNX so I decided to try and modify it to deploy for .Net Core.

构建脚本通过调用以下命令来创建其部署程序包:msbuild.exe /t:Build,FileSystemPublish 在打开日志详细程度并阅读了相关的msbuild文件后,我学到了以下内容:

The build script creates its deployment package by calling: msbuild.exe /t:Build,FileSystemPublish After turning up log verbosity and reading through the relevant msbuild files I have learned the following:

"Build"目标最终使用dnx.exe编译项目.因为project.json文件同时包含dnx451和coreclr TFM,所以此步骤为两个框架都生成了构建输出-到目前为止,一切都很好.

The "Build" target ultimately uses dnx.exe to compile the project. Because the project.json file includes both dnx451 and coreclr TFMs this step produces build output for both frameworks - so far so good.

但是,FileSystemPublish目标似乎仅输出针对.Net 4.5.1运行时的msdeploy程序包.从日志中,我可以看到执行FileSystemPublish目标最终会发出"dnu publish"命令,在我的情况下,将"dnx-clr-win-x86.1.0.0-beta6"作为-runtime参数传递.当我跟踪面包屑以从哪里获取值"dnx-clr-win-x86.1.0.0-beta6"时,我最终遇到了Microsoft.DNX.Tasks.dll中的"GetRuntimeToolingPath"任务.该任务似乎在global.json中查找,以确定要使用的正确运行时,但奇怪的是,在创建返回字符串之前,内部使用"x86"和"clr"覆盖了此值.

However, the FileSystemPublish target seems to only output an msdeploy package that targets the .Net 4.5.1 runtime. From the logs I could see executing the FileSystemPublish target ultimately issues a "dnu publish" command and in my cases passes "dnx-clr-win-x86.1.0.0-beta6" as the -runtime parameter. When I followed the breadcrumbs to find out where it was getting the value "dnx-clr-win-x86.1.0.0-beta6" from I eventually ended up in the "GetRuntimeToolingPath" task in Microsoft.DNX.Tasks.dll. This task seems to look in global.json to determine the correct runtime to use but strangely appears to internally override this value with "x86" and "clr" before creating the return string.

如果我正确地理解了一切,似乎FileSystemPublish目标(在Microsoft.DNX.Publishing.targets中)本质上(间接地)被硬连线为在生成软件包输出时使用x86,完整的.Net框架DNX.在这一点上,我对如何获得此生成过程以生成.Net Core程序包感到困惑.

If I have interpreted things correctly, it seems that the FileSystemPublish target (in Microsoft.DNX.Publishing.targets) is essentially (indirectly) hard wired to use the x86, full .Net framework DNX when it produces its package output. At this point I am stuck for how to get this build process to produce a .Net Core package.

我的问题是,为什么将FileSystemPublish耦合到x86完整的.Net DNX上,鉴于这种情况(除非我误会了),建议为ASPNET 5应用程序生成msdeploy软件包的推荐方法是什么?网络核心?

My question is why would FileSystemPublish be coupled to the x86 full .Net DNX and given this appears to be the case (unless I am mistaken) what is the recommended way to produce an msdeploy package for an ASPNET 5 app that targets .Net core?

现在,我有一个解决方法.我可以将/p:RuntimeToolingDirectory="C:\Users\buildguest\.dnx\runtimes\dnx-coreclr-win-x64.1.0.0-beta6"作为参数传递给msbuild. 这将覆盖GetRuntimeToolPath中的默认逻辑,并强制其使用.Net Core.这种方法有效,但是感觉像是一种骇客,所以我将问题悬而未决,以寻求更好的答案.

For now I have a workaround. I can pass /p:RuntimeToolingDirectory="C:\Users\buildguest\.dnx\runtimes\dnx-coreclr-win-x64.1.0.0-beta6" as a parameter to msbuild. This overrides the default logic in the GetRuntimeToolPath and forces it to use .Net Core. This works but feels like a hack so I'm leaving the question open for a better answer.

推荐答案

要发布Core CLR,可以将msbuild参数"PublishDNXVersion"作为dnx-coreclr-win-x64.1.0.0-beta6传递.

To publish Core CLR, you can pass the msbuild parameter 'PublishDNXVersion' as dnx-coreclr-win-x64.1.0.0-beta6.

msbuild <project>.xproj /p:deployOnBuild=true;PublishDNXVersion=dnx-coreclr-win-x64.1.0.0-beta6

这篇关于如何为以.Net Core为目标的ASP.Net 5应用程序构建MSDeploy程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆