ASP.NET 核心迁移从 2.1 -> 2.2 Azure 部署中的依赖项问题

ASP.NET Core Migration from 2.1 -> 2.2 Issue with dependencies in Azure deployment

我在将 ASP.NET Core 2.2 应用程序部署到 Azure 时遇到 Kudu 问题。该应用程序已从 2.1 -> 2.2 迁移,并在升级前部署得很好。

我用这个document作为参考

部署错误日志:

    Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment.
  Restoring packages for D:\home\site\repository\Source\PlanetDiego.Core\PlanetDiego.Core.csproj...
D:\Program Files (x86)\dotnet\sdk.2.100\NuGet.targets(114,5): error : Could not find file 'D:\home\.nuget\newtonsoft.json.0.4\newtonsoft.json.6.0.4.nupkg'. [D:\home\site\repository\Source\PlanetDiego.sln]
Failed exitCode=1, command=dotnet restore "D:\home\site\repository\Source\PlanetDiego.sln"
An error has occurred during web site deployment.
\r\nD:\Program Files (x86)\SiteExtensions\Kudu.11121.3655\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"

有趣的是,每次部署尝试 returns 都会出现不同的错误依赖错误:

Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment.
  Restoring packages for D:\home\site\repository\Source\PlanetDiego.Core\PlanetDiego.Core.csproj...
D:\Program Files (x86)\dotnet\sdk.2.100\NuGet.targets(114,5): error : Could not find file 'D:\home\.nuget\awssdk.core.3.0\awssdk.core.3.3.0.nupkg'. [D:\home\site\repository\Source\PlanetDiego.sln]
Failed exitCode=1, command=dotnet restore "D:\home\site\repository\Source\PlanetDiego.sln"
An error has occurred during web site deployment.
\r\nD:\Program Files (x86)\SiteExtensions\Kudu.11121.3655\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"

csproj 文件。如您所见,不依赖于 newtonsoft.json.6.0.4.nupkg 或 awssdk.core.3.3.0.nupkg。指定的版本分别为 12.0.1 和 3.3.29。 我尝试转到 Azure 中的 Kudu 控制台并删除 D:\home\site\deployments\tools 文件夹中的 deploy.cmd 和 deploymentCacheKey。可惜没有效果。

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AssemblyName>PlanetDiego.Core</AssemblyName>
    <PackageId>PlanetDiego.Core</PackageId>
    <LangVersion>latest</LangVersion>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AWSSDK.Core" Version="3.3.29.13" />
    <PackageReference Include="AWSSDK.S3" Version="3.3.31" />
    <PackageReference Include="AWSSDK.SimpleEmail" Version="3.3.7.15" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
    <PackageReference Include="TweetinviAPI" Version="4.0.0" />
  </ItemGroup>

</Project>

我似乎能够在 Visual Studio 代码中使用目标框架 2.1 和 Azure 工具扩展部署应用程序。 dotnet publish -c Relase,然后右键单击 bin/Release/netcoreapp2.1/publish 文件夹并部署到 Web App。

SDK 2.2 是 new,可能它现在在 Azure 上坏了。

尝试删除 D:\home\.nuget\ 目录,然后重新 运行 restore/deployment。