简体   繁体   English

Azure App Service升级dotnet核心

[英]Azure App Service upgrade dotnet core

My asp.net core site fails to run after publishing. 我的asp.net核心站点在发布后无法运行。 After a bit of troubleshooting I saw the dotnet version on my azure app service was still 1.0.0-rc3-004530. 经过一些故障排除后,我看到我的Azure应用服务上的dotnet版本仍然是1.0.0-rc3-004530。 How do I upgrade it to 1.1? 如何将其升级到1.1?

Answer 回答

  1. Create a global.json file in your project's root directory. 在项目的根目录中创建global.json文件。
  2. Set the SDK to a version that is installed both on your machine and on Azure. 将SDK设置为在计算机和Azure上安装的版本。

Now if your app works locally it will also work remotely. 现在,如果您的应用在本地工作,它也可以远程工作。 Here is an example global.json file. 这是一个示例global.json文件。

{
    "sdk": { "version": "1.0.0-preview2-1-003177" }
}

Explanation 说明

The dotnet --version command does not indicate the .NET Core Runtime version. dotnet --version命令不表示.NET Core Runtime版本。 It is hard to determine which version of the .NET Core SDK is for what version of the .NET Core runtime. 很难确定哪个版本的.NET Core SDK适用于哪个版本的.NET Core运行时。 What follows is some evidence for that and some ideas on how to make sense of it. 以下是对此的一些证据以及如何理解它的一些想法。

First. 第一。 Log in to the Azure Portal. 登录Azure门户。 Then go to yourapp.scm.azurewebsites.net. 然后去yourapp.scm.azurewebsites.net。 Click on Debug Console > PowerShell and run this: 单击Debug Console> PowerShell并运行以下命令:

PS> dir "D:\Program Files (x86)\dotnet\sdk" -name

1.0.0-preview1-002702
1.0.0-preview2-003121
1.0.0-preview2-003131
1.0.0-preview2-003156         <-- this is for .NET Core 1.0.3
1.0.0-preview2-1-003177       <-- this is for .NET Core 1.1
1.0.0-preview2.1-003155
1.0.0-preview3-004056
1.0.0-preview4-004233
1.0.0-rc3-004530              <-- this is also for .NET Core 1.1

That is the list of the .NET Core SDK versions installed in Azure. 这是Azure中安装的.NET Core SDK版本的列表。 The last one in the list is the one Azure will use by default. 列表中的最后一个是Azure默认使用的一个。 The versions all start with 1.0.0 . 版本都以1.0.0开头。

Second. 第二。 Do some research at the .NET Core Downloads page . .NET Core下载页面上做一些研究。 We can find some information about how SDK versions match runtime versions. 我们可以找到有关SDK版本如何匹配运行时版本的一些信息。 This is a current download: 这是当前的下载:

下载适用于Windows的.NET Core 1.1 SDK x86

It is downloading the .NET Core 1.1 SDK x86 for Windows; 它正在下载适用于Windows的.NET Core 1.1 SDK x86; the version number is 1.0.0-preview2-1-003177 . 版本号为1.0.0-preview2-1-003177 (It also happens that 1.0.0-rc3-004530 is for .NET Core 1.1). 1.0.0-rc3-004530也适用于.NET Core 1.1)。

Third. 第三。 From the command line or PowerShell, compare the output of these three commands. 从命令行或PowerShell中,比较这三个命令的输出。

PS> dotnet
PS> dotnet --info
PS> dotnet --version

The first command shows the most relevant information about the version of .NET Core that you are running. 第一个命令显示有关您正在运行的.NET Core版本的最相关信息。 The rest give details about the exact version of the SDK. 其余部分详细介绍了SDK的确切版本。

Summary What does this mean for you? 总结这对您意味着什么? You do not need to upgrade Azure - in Azure you are already using an SDK for .NET Core 1.1. 您无需升级Azure - 在Azure中,您已经在使用SDK for .NET Core 1.1。 Instead you need to ensure you are using the same SDK version on Azure that you are using locally. 相反,您需要确保在Azure上使用与本地使用相同的SDK版本。 My answer shows you how to do that. 我的回答告诉你如何做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM