将我的ASP.NET网站从.NET 2.2 Core Preview 2升级到.NET 2.2 Core Preview 3-程序员宅基地

技术标签: spring  python  区块链  java  docker  

I've recently returned from a month in South Africa and I was looking to unwind while the jetlagged kids sleep. I noticed that .NET Core 2.2 Preview 3 came out while I wasn't paying attention. My podcast site runs on .NET Core 2.2 Preview 2 so I thought it'd be interesting to update the site. That means I'd need to install the new SDK, update the project references, ensure it builds in Azure DevOps's CI/CD Pipeline, AND deploys and runs in Azure.

我最近刚从南非一个月回来,所以我想放松一下那些身手不稳的孩子睡觉的时候。 我注意到.NET Core 2.2预览版3出炉时我没有注意。 我的播客站点在.NET Core 2.2 Preview 2上运行,因此我认为更新站点会很有趣。 这意味着我需要安装新的SDK,更新项目引用,确保它构建在Azure DevOps的CI / CD管道中,并在Azure中部署和运行。

Let's see how it goes. I'm a little out of it but I'm writing this blog post AS I DO THE WORK so you'll see my train of thought with no editing.

让我们看看进展如何。 我有点不高兴了,但是我正在写这篇博客,因为我在做工作,所以您将看到我的思路而无需编辑。

Ok, what version of .NET Core does this machine have?

好的,这台计算机有什么版本的.NET Core?

C:\Users\scott> dotnet --version
2.2.100-preview2-009404
C:\Users\scott> dotnet tool update --global dotnet-outdated
Tool 'dotnet-outdated' was successfully updated from version '2.0.0' to version '2.1.0'.

Looks like I'm on Preview 2 as I guessed. I'll take a moment and upgrade one Global Tool I love - dotnet-outdated - in case it's been updated since I've been out. Looks like it has a minor update. Dotnet Outdated is a great utility for checking references and you should absolutely be using it or another tool like NuKeeper or Dependabot.

我猜好像我正在预览2中。 我将花一点时间升级一个我喜欢的全球工具-dotnet已过时-以防自从我离开以后就进行了更新。 看起来它有较小的更新。 Dotnet过时了是用于检查引用的好工具,您绝对应该使用它或其他工具,例如NuKeeperDependabot

I'll head over to https://www.microsoft.com/net/download/dotnet-core/2.2 and get .NET Core 2.2 Preview 3. I'm building on Windows but I may want to update my Linux (WSL) install and Docker images later.

我将转到https://www.microsoft.com/net/download/dotnet-core/2.2并获取.NET Core 2.2 Preview 3 。 我在Windows上构建,但稍后可能要更新Linux(WSL)安装和Docker映像。

All right, installed. Check it with dotnet --version to confirm it's correct:

好的,已安装。 用dotnet --version检查它,以确认它是正确的:

C:\Users\scott> dotnet --version
2.2.100-preview3-009430

Let's try to build my podcast website. Note that it consists of two projects, the main website on ASP.NET Core, and Unit Tests with XUnit and Selenium.

让我们尝试建立我的播客网站。 请注意,它由两个项目组成,ASP.NET Core上的主要网站,以及XUnit和Selenium的单元测试

D:\github\hanselminutes-core [main ≡]> dotnet build
Microsoft (R) Build Engine version 15.9.8-preview+g0a5001fc4d for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restoring packages for D:\github\hanselminutes-core\hanselminutes.core.tests\hanselminutes.core.tests.csproj...
Restore completed in 80.05 ms for D:\github\hanselminutes-core\hanselminutes.core.tests\hanselminutes.core.tests.csproj.
Restore completed in 25.4 ms for D:\github\hanselminutes-core\hanselminutes.core\hanselminutes-core.csproj.
D:\github\hanselminutes-core\hanselminutes.core.tests\hanselminutes.core.tests.csproj : error NU1605: Detected package downgrade: Microsoft.AspNetCore.App from 2.2.0-preview3-35497 to 2.2.0-preview2-35157. Reference the package directly from the project to select a different version. [D:\github\hanselminutes-core\hanselminutes-core.sln]

The dotnet build fails, which make sense, because it's saying hey, you're asking for 2.2 Preview 2 but I've got Preview 3 all ready for you!

dotnet构建失败,这很有道理,因为这是说嘿,您要使用2.2 Preview 2,但我已经为您准备了Preview 3!

Detected package downgrade: Microsoft.AspNetCore.App from 2.2.0-preview3-35497 to 2.2.0-preview2-35157

Let's see what "dotnet outdated" says about this!

让我们看看“ dotnet过时”对此有何评论!

dotnet outdated says there's a few packages I need to update

Cool! I love these dependency tools and the community around them. You can see that it's noticed the Preview 2 -> Preview 3 opportunity, as well as a few other smaller minor or patch version bumps.

凉! 我喜欢这些依赖工具以及周围的社区。 您会发现它注意到了Preview 2-> Preview 3的机会,以及其他一些较小的次要版本或补丁版本。

I can run dotnet outdated -u to automatically update the references, but I'll want to treat the "reference" of "Microsoft.AspNetCore.App" a little differently and use implicit versioning. You don't want to include a specific version - as I did - for this package.

我可以运行过时的dotnet -u来自动更新引用,但是我想对“ Microsoft.AspNetCore.App”的“引用”进行一些不同的处理,并使用隐式版本控制。 您不希望像我一样为该程序包包含特定版本。

Per the docs for .NET Core 2.1 and up:

根据.NET Core 2.1及更高版本的文档

Remove the "Version" attribute on the package reference to Microsoft.AspNetCore.App. Projects which use <Project Sdk="Microsoft.NET.Sdk.Web"> do not need to set the version. The version will be implied by the target framework and selected to best match the way ASP.NET Core 2.1 works. (See below for more information.)

删除对Microsoft.AspNetCore.App的程序包引用上的“版本”属性。 使用<Project Sdk="Microsoft.NET.Sdk.Web">不需要设置版本。 该版本将由目标框架隐含并选择为与ASP.NET Core 2.1的工作方式最匹配。 (请参阅下面的详细信息。)

Doing this also fixes the build because it picks up the latest 2.2 SDK automatically! Now I'll run my Unit Tests (with code coverage) and see how it works. Cool all tests pass (including Selenium).

这样做还可以修复构建,因为它会自动获取最新的2.2 SDK! 现在,我将运行单元测试(代码覆盖率),并查看其工作原理。 冷却所有测试通过(包括Selenium)。

88% Code Coverage

It builds locally, will it build in Azure DevOps when I check it in to GitHub?

它在本地构建,当我签入GitHub时会在Azure DevOps中构建吗?

Azure DevOps

I added a .NET Core SDK installer step when I set up my Azure Dev Ops Pipeline. This is where I'm explicitly installing a Preview version of the .NET Core SDK.

设置Azure Dev Ops管道时,添加了.NET Core SDK安装程序步骤。 这是我明确安装.NET Core SDK预览版的地方。

While I'm in here I noticed the Azure DevOps pipeline was using NuGet 4.4.1. I run "nuget update -self" on my local machine and got 4.7.1, so I updated that version as well to make the CI/CD pipeline reflect my own machine.

当我在这里时,我注意到Azure DevOps管道正在使用NuGet 4.4.1。 我在本地计算机上运行“ nuget update -self”,并获得了4.7.1,所以我也更新了该版本,以使CI / CD管道反映我自己的计算机。

Now I'll git add, git commit (using verified/signed GitHub commits with my PGP Key and Yubikey):

现在,我将进行git add,git commit(使用带有我的PGP Key和Yubikey的经过验证/签名的GitHub提交):

D:\github\hanselminutes-core [main ≡ +0 ~2 -0 !]> git add .
D:\github\hanselminutes-core [main ≡ +0 ~2 -0 ~]> git commit -m "bump to 2.2 Preview 3"
[main 7a84bc7] bump to 2.2 Preview 3
2 files changed, 16 insertions(+), 13 deletions(-)

Add in a Git Push...and I can see the build start in Azure DevOps:

添加一个Git Push ...,我可以在Azure DevOps中看到构建开始:

CI/CD pipeline build starting

Cool. While that's building, I'll make sure my existing Azure App Service (website) installation is ready to receive the deployment (assuming the build succeeds). Since I'm using an ASP.NET Core Preview build I'll want to make sure I have the Preview Site Extension installed, per the docs.

凉。 在构建过程中,我将确保现有的Azure应用服务(网站)安装已准备就绪,可以接收部署(假设构建成功)。 由于我使用的是ASP.NET Core预览版本,因此我要确保每个文档都已安装了预览站点扩展

If I visit the Site Extensions menu item in the Azure Portal I can see I've got .NET Core 2.2 Preview 2, but there's an update available, as expected.

如果我访问Azure门户中的“站点扩展”菜单项,则可以看到我已经拥有.NET Core 2.2预览版2,但是正如预期的那样,有可用的更新。

Update Available

I'll click this extension and then click Update. This extension's job is to make sure the App Service gets Preview versions of the .NET Core SDK. Only released (GA - general availability) SDKs are installed by default.

我将单击此扩展名,然后单击“更新”。 此扩展程序的工作是确保App Service获得.NET Core SDK的预览版。 默认情况下,仅安装发布的(GA-通用)SDK。

OK, .NET Core 2.2 is all updated in Azure, so I'll confirm that it's deployed as well in Azure DevOps. Yes, I'm deploying into Production without a net. Seriously, though, if there is an issue I'll just rollback. If I was deeply serious about downtime I'd be doing all this in Staging.

好的,.NET Core 2.2已在Azure中全部更新,因此我将确认它也在Azure DevOps中进行了部署。 是的,我没有网络就可以部署到生产环境中。 严重的是,如果出现问题,我将回滚。 如果我非常认真地考虑停机时间,那么我将在暂存中进行所有这些操作。

image

Successful local test, successful CI/SD build and test, successful deployment, and the site is back up now running on ASP.NET Core 2.2 Preview 3. It took about 45 min to do the work while simultaneously taking these screenshots and writing this blog post during the slow parts.

成功的本地测试,成功的CI / SD构建和测试,成功的部署以及站点现在都在ASP.NET Core 2.2 Preview 3上运行。 完成这项工作大约需要45分钟,同时获取这些屏幕截图并在较慢的部分中撰写此博客文章。

Good night everyone!

各位晚安!

翻译自: https://www.hanselman.com/blog/updating-my-aspnet-website-from-net-22-core-preview-2-to-net-22-core-preview-3

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/cunfuxiao7305/article/details/109050757

智能推荐

open vswitch研究:openflow I_live for fast failover group-程序员宅基地

文章浏览阅读9.6k次。关于openflow的规范不是本文讨论范畴,这篇主要讨论OVS对openflow的支持,代码基本都在ofproto/目录下struct ofproto代表了一个openflow switch的模型,是一个"接口类"struct ofproto { struct hmap_node hmap_node; /* In global 'all_ofprotos' hmap. */_live for fast failover group

Lua 打乱数组顺序_lua数组打断顺序-程序员宅基地

文章浏览阅读9.3k次。function shuffle(t) if type(t)~="table" then return end local l=#t local tab={} local index=1 while #t~=0 do local n=math.random(0,#t) if t[n]~=nil then_lua数组打断顺序

企业级静态代码分析工具清单_源码扫描 商业软件-程序员宅基地

文章浏览阅读4.1k次。如果要选择一款企业级静态源代码安全扫描工具,那么Gartner 2021应用程序安全测试 (AST) 魔力象限,就可以给我们在产品选型提供很重要的参考。本文整理的是一份商业静态源代码分析工..._源码扫描 商业软件

【汽修帮手】数据采集,爬虫,根据pdf文件流合并pdf文件-程序员宅基地

文章浏览阅读1.6k次,点赞35次,收藏11次。【代码】【汽修帮手】数据采集,爬虫,根据pdf文件流合并pdf文件。

异质图综述 - Graph Neural Networks for Graphs with Heterophily: A Survey(CoRR 2022)-程序员宅基地

文章浏览阅读3.4k次,点赞6次,收藏31次。异质图综述 - Graph Neural Networks for Graphs with Heterophily: A Survey(CoRR 2022)_graph neural networks for graphs with heterophily: a survey

【有向目标检测】SCRDet_什么是有向目标检测-程序员宅基地

文章浏览阅读858次,点赞24次,收藏18次。引入 IoU 常数因子∣−logIoU∣∣Lregvjvj∣∣Lreg​vj​vj​∣∣−logIoU∣​在Smooth L1 Loss中,如下面公式中的回归部分在边界情况下,新的损失函数近似等于0,消除了损失的突增。新的回归损失可分为两部分,smooth L1回归损失函数取单位向量确定梯度传播的方向,而IoU表示梯度的大小,这样loss函数就变得连续。_什么是有向目标检测

随便推点

摩尔投票法/消消乐-程序员宅基地

文章浏览阅读42次。投票法的精髓就是,如果你找n个数中大于n/m的数,那么你按m个数消消乐,你会发现消n/m次后,剩余最多(m-1)个数,所以你检测一下这m-1个数在数组出现的次数,这其实是O(n)的;因此,你也只用建立m-1个变量,一旦多了一个变量,那么就按m个消消乐;举个例子:如果m=2,那么就是按2消除,记录m-1=1个参数就可以了;如果m=3,那么就是按3消,记录m-1=2个参数就可以了;如果m=2,剩下的就是了,因为你比别人多,消完了就可以了;而m=a>2,只能保证有剩下的,不能保证都是你需要的;

Java知识体系总结(2021版)_java知识体系详细总结(2021版)-程序员宅基地

文章浏览阅读126次。一、Java基础知识1、基础知识分类 内容 链接 Java基础 【Java知识点详解 1】缓存 https://blog.csdn.net/guorui_java/article/details/104557984 Java基础 【Java知识点详解 2】动态代理 https://blog.csdn.net/guorui_java/article/details/108630273 Java基础 【Java_java知识体系详细总结(2021版)

磁力计LIS2MDL开发(2)----电子罗盘_电子罗盘csdn-程序员宅基地

文章浏览阅读1.4w次,点赞21次,收藏33次。本文将介绍如何使用 LIS2MDL 传感器来读取数据来转化为指南针。地磁场强度范围约为 23,000 至 66,000 nT ,并且可以建模为磁偶极子,其场线起源于地球地理南部附近的点,并终止于磁场附近的点。磁场具有七个分量,如图 所示。x,y和z分别表示北分量,东分量和垂直分量的磁场强度。H代表总水平强度,F代表磁场的总强度,而D和I分别代表磁偏角和磁倾角。_电子罗盘csdn

sklearn学习之使用sklearn进行特征选择_sklearn。feature_selection-程序员宅基地

文章浏览阅读7.7k次,点赞4次,收藏42次。在本节中我们将使用sklearn.feature_selection模块中的类在高维度的样本集上进行特征选择、降维来提升估计器的性能。1. Removing features with low variance方差选择法sklearn.feature_selection.VarianceThreshold(threshold=0.0)方差选择法是一种进行特征选择的简单的baseline方法,..._sklearn。feature_selection

IOT开发中,什么时候选择RTOS系统?_iot要用到rtos吗-程序员宅基地

文章浏览阅读93次。大部分主流MCU都是支持的,例如:stm32、ESP32,但实际开发中,也见过不支持的MCU,例如上海博通集成的蓝牙芯片:BK3633,该芯片在实际开发中,因为使用了第三方开发的蓝牙内核:RivieraWaves,它本身是一个实时操作系统,但是对于开发者来讲,它的内核因为不是开源的,所以无法像FreeRTOS那样,随时开辟线程。_iot要用到rtos吗

notes-程序员宅基地

文章浏览阅读416次,点赞9次,收藏8次。轻量级锁升级为重量级锁:这个时候,只要我们的线程发生了竞争,并且CAS替换失败,就会发起锁膨胀,升级为重量级锁 (针对的是一个对象实例)真正的锁升级,是依赖于 class的,而并不是依赖于 某一个new出来的对象 (偏向锁升级为轻量级锁)真正的锁升级,是依赖于 当前new出来的对象的 (轻量级锁升级为重量级锁)轻量级锁 ---> 重量级锁:释放锁 (前4步)并唤醒等待线程。如果是调用join方法的锁对象,则释放。让出CPU时间片,进入等待队列。具体要看当前的锁对象是谁。