我们可以使用 Kudu 将 C# 7 Web 应用程序部署到 Azure 吗? [英] Can we deploy a C# 7 web app to Azure using Kudu?

查看:35
本文介绍了我们可以使用 Kudu 将 C# 7 Web 应用程序部署到 Azure 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从 Visual Studio 2017 发布以来,我们可以使用新的 C# 7 功能,我预计这将在 Azure Web 应用程序上部署时起作用.

Since Visual Studio 2017 is released and we can use the new C# 7 features I expected this will work when deploying on Azure Web apps.

不幸的是,我们在使用持续部署 (kudu git deploy) 时看到编译错误,因此 Azure 似乎还不支持新工具链.

Unfortunately we're seeing compile errors when using continuous deployment (kudu git deploy) so it seems Azure doesn't support the new toolchain yet.

我们现在可以做些什么来让它工作(除了直接发布程序集之外)?

Is there anything we can do to get this to work now (besides publishing the assemblies directly)?

推荐答案

因为我们在 Azure 中还没有 msbuild15.如果您想在持续集成中使用 c#7 功能,您可能需要一些解决方法

since we don't yet have msbuild15 in Azure. if you want to use c#7 features with continuous integration, you may need some workaround

  1. 对于 dotnet 核心网络解决方案,您可以在 Azure 中构建它开箱即用.(它使用自己的 dotnet msbuild.dll)[存储库示例]
  2. asp.net web 解决方案,需要将Microsoft.Net.Compilers 2.0+ nuget 包添加到应用新语言特性的项目中.例如,如果解决方案中的类库使用新语法,则需要将 nuget 包添加到该 lib 项目.(如果您引用此 nuget 包,则会导入新的 c# 编译器)[存储库示例]
  3. 最后对于混合解决方案(dotnet core web app + .NET framework class lib),你需要为.NET framework lib项目运行nuget restore独立 因为 dotnet restore 不向后兼容,它不能从旧的构建系统恢复项目.我通过破解我的 deploy.cmd [存储库示例]
  1. for dotnet core web solution, you can build it in Azure out of the box. (it uses its own dotnet msbuild.dll) [repository sample]
  2. for asp.net web solution, you need to add Microsoft.Net.Compilers 2.0+ nuget package to the project where the new language feature is applied. For example, if a class library in the solution is using the new syntax, you need to add nuget package to that lib project. (the new c# compiler is thus imported if you refer this nuget package) [repository sample]
  3. finally for mixed solution (dotnet core web app + .NET framework class lib), you need to run nuget restore for the .NET framework lib project independently since dotnet restore is not backwards compatible, it cannot retore project from the old build system. I did this by hacking my deploy.cmd [repository sample]

这些解决方法要么尝试
模仿msbuild15(case1:dotnet msbuild.dll,case2:编译成nuget包)
或者模仿nuget4.0(案例3:同时运行dotnet restorenuget3.5 restore)

these workarounds either try to
imitate msbuild15 (case1: dotnet msbuild.dll, case2: compiler as a nuget package)
or imitate nuget4.0 (case 3: run both dotnet restore and nuget3.5 restore)

我们正在为 Azure 构建这些工具,它们应该很快就会推出.您可以在 github

we are in the process of building these tools for Azure, they should be out soon. you can stay updated on github

这篇关于我们可以使用 Kudu 将 C# 7 Web 应用程序部署到 Azure 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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