.deploy_git_使用git deploy将ASP.NET Core 1.1应用程序发布到Azure

.deploy_git

.deploy_git

I took an ASP.NET Core 1.0 application and updated its package references to ASP.NET 1.1 today. I also updated to my SDK to the Current (not the LTS - Long Term Support version). Everything worked great building and running locally, but then I made a new Web App in Azure and did a quick git deploy.

我今天采用了ASP.NET Core 1.0应用程序,并将其程序包引用更新为ASP.NET 1.1。 我也将我的SDK更新到当前版本(不是LTS-长期支持版本)。 一切都很好地构建并在本地运行,但是随后我在Azure中创建了一个新的Web应用程序并进行了快速git部署

Deploying ASP.NET Core 1.1 to Azure

Basically:

基本上:

c:\aspnetcore11app> azure site create "aspnetcore11test" --location "West US" --git
c:\aspnetcore11app> git add .
c:\aspnetcore11app> git commit -m "initial"
c:\aspnetcore11app> git push azure master

Then I watched the logs go by. You can watch them at the command line or from within the Azure Portal under "Log Stream."

然后我看着日志过去了。 您可以在命令行或从Azure门户中“日志流”下查看它们。

The deployment failed when Azure was building the app and got this error:

当Azure生成应用程序并出现以下错误时,部署失败:

Build started 11/25/2016 6:51:54 AM.
2016-11-25T06:51:55         1>Project "D:\home\site\repository\aspnet1.1.xproj" on node 1 (Publish target(s)).
2016-11-25T06:51:55         1>D:\home\site\repository\aspnet1.1.xproj(7,3): error MSB4019: The imported project "D:\Program Files (x86)\dotnet\sdk\1.0.0-preview3-004056\Extensions\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
2016-11-25T06:51:55         1>Done Building Project "D:\home\site\repository\aspnet1.1.xproj" (Publish target(s)) -- FAILED.
2016-11-25T06:51:55    

See where it says "1.0.0-preview3-004056" in there? Looks like Azure Web Apps has some build that isn't the one that I have. Theirs has the new csproj/msbuild stuff and I'm staying a few steps back waiting for things to bake.

看到那里说“ 1.0.0-preview3-004056”的地方吗? 看起来Azure Web Apps的构建不是我所拥有的。 他们有新的csproj / msbuild东西,我要退后几步等待东西烘烤。

Remember that unless you specify the SDK version, .NET Core will use whatever is the latest one on the box.

请记住,除非您指定SDK版本,否则.NET Core将使用包装盒上最新的版本。

Well, what do I have locally?

好吧,我在当地有什么?

C:\aspnetcore11app>dotnet --version
1.0.0-preview2-1-003177

OK, then that's what I need to use so I'll make a global.json at the root of my project, then move my code into a folder under "src" for example.

好的,那就是我需要使用的,所以我将在项目的根目录下创建一个global.json,然后将代码移动到“ src”下的文件夹中。

{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-1-003177"
}
}

Here I'm "pinning" the same SDK version. This will tell Azure (or you, if I gave you the code) to use this SDK version when building.

在这里,我“固定”了相同的SDK版本。 这将告诉Azure(或您,如果我给您提供了代码)在构建时使用此SDK版本。

Now I'll redeploy with a git add, commit, and push. It works.

现在,我将使用git add,commit和push进行重新部署。 有用。

I think this should be easier, but I'm not sure how it should be easier. Does this mean that everyone should have a global.json with a preferred version? If you have no preferred version should Azure give a smarter error if it has an incompatible newer one?

我认为这应该更容易,但是我不确定应该如何更容易。 这是否意味着每个人都应该拥有带有首选版本的global.json? 如果没有首选版本,如果Azure具有不兼容的较新版本,Azure应该给出更智能的错误吗?

The learning here for me is that not having a global.json basically says "*.*" to any cloud build servers and you'll get whatever latest SDK they have. It could stop working any day.

对我而言,这里的学习是,没有global.json基本上对任何云构建服务器都说“ *。*”,您将获得它们拥有的任何最新SDK。 它有一天可能会停止工作。

Sponsor: Big thanks to Octopus Deploy! Do you deploy the same application multiple times for each of your end customers? The team at Octopus have taken the pain out of multi-tenant deployments. Check out their latest 3.4 release!

赞助商:非常感谢章鱼部署 您是否为每个最终客户多次部署相同的应用程序? Octopus的团队已摆脱了多租户部署的痛苦。 看看他们最新的3.4版本

翻译自: https://www.hanselman.com/blog/publishing-aspnet-core-11-applications-to-azure-using-git-deploy

.deploy_git

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值