0

我的构建成功构建 + 部署在 Azure 集群中。 VSTS 构建任务

我没有代码更改。我比较了工作和不工作的构建工件。我的 MyCompany.MyService.Api.deps.json 文件中有新条目:

    ...
    "compilationOptions": {
        "defines": [
    ...
          "NETFRAMEWORK",
    ...
        ],
    ...
              "Microsoft.Bcl.Build": "1.0.21",
              "System.IdentityModel": "4.0.0.0",
              "System.ServiceModel.Web": "4.0.0.0",
              "System.Web.Services": "4.0.0.0",
              "System.Runtime.Caching": "4.0.0.0",
              "System.ServiceModel.Activation": "4.0.0.0"
            },
    ...
              "System.Transactions": "4.0.0.0",
              "System.Web": "4.0.0.0",
              "System.Diagnostics.Tracing.Reference1": "4.0.20.0",
              "System.Runtime.Serialization.Primitives.Reference": "4.0.10.0",
              "System.Runtime.Serialization.Xml.Reference": "4.0.10.0"
            },
    ...
          "System.Runtime.Reference1": "4.0.20.0",
          "System.Threading.Tasks.Reference1": "4.0.10.0",
          "System.Resources.ResourceManager.Reference1": "4.0.0.0",
          "System.Globalization.Reference1": "4.0.10.0",
          "System.Diagnostics.Tools.Reference1": "4.0.0.0",
          "System.Diagnostics.Debug.Reference1": "4.0.10.0",
          "System.Linq.Reference1": "4.0.0.0",
          "System.Collections.Reference1": "4.0.10.0",
          "System.Threading.Reference1": "4.0.10.0",
          "System.Runtime.Extensions.Reference1": "4.0.10.0",
          "System.IO.Reference1": "4.0.10.0",
          "System.Runtime.InteropServices.Reference1": "4.0.20.0",
          "System.Text.Encoding.Reference1": "4.0.10.0",
          "System.Reflection.Primitives.Reference1": "4.0.0.0",
          "System.Reflection.Reference1": "4.0.10.0",
          "System.Text.Encoding.Extensions.Reference1": "4.0.10.0",
          "System.ComponentModel.Reference": "4.0.0.0",
          "System.Reflection.Extensions.Reference1": "4.0.0.0"
...

在过去的几个月里,我成功地构建和部署了。然而在过去的 5 天里,从 VSTS 构建构建的代码无法部署到集群。我的 API 服务无法启动,并且出现以下错误。请建议我如何调试。代码在我的本地集群中成功部署和启动。

Unhealthy event: SourceId='System.RA', Property='ReplicaOpenStatus', HealthState='Warning', ConsiderWarningAsError=false.
Replica had multiple failures during open on _ntsfmain_0. API call: IStatelessServiceInstance.Open(); Error = System.Collections.Generic.KeyNotFoundException (-2146232969)
The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.CandidateResolver.ComputeClassification(String dependency)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.CandidateResolver.ComputeClassification(String dependency)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.CandidateResolver.ComputeClassification(String dependency)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.CandidateResolver.d__4.MoveNext()
at System.Linq.Enumerable.d__17`2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services)
at MyCompany.MyService.Api.Startup.ConfigureDevelopmentServices(IServiceCollection services) in C:\agent_C\_work\19\s\Source\MyCompany.MyService.Api\Startup.cs:line 39
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at MyCompany.MyService.Api.Api.<>c__DisplayClass4_0.b__1(String url, AspNetCoreCommunicationListener listener) in C:\agent_C\_work\19\s\Source\MyCompany.MyService.Api\Api.cs:line 91
at Microsoft.ServiceFabric.Services.Communication.AspNetCore.AspNetCoreCommunicationListener.OpenAsync(CancellationToken cancellationToken)
at Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__13.MoveNext()
For more information see: http://aka.ms/sfhealth
4

1 回答 1

0

这是一个与 asp.net core 2.1 相关的已知错误。几周前我们遇到了同样的问题。

核心 2.1 的安装存在一些相互冲突的依赖关系,会影响其他 dot net 版本。VSTS 构建环境或 SF 可能已升级到核心 2.1 并影响了您的旧构建。

你可以:

降级到 2.0:在我们的案例中,我们有一些针对核心 2.1 的服务以及一些 1.1 和 2.0,我们将所有服务降级到核心 2.0,问题得到了解决。

或者,

AddMvc()您可以在您的 api行之前添加以下代码来修复依赖关系问题。

看起来像这样:

var manager = new ApplicationPartManager();
manager.ApplicationParts.Add(new AssemblyPart(typeof(Startup).Assembly));
manager.ApplicationParts.Add(new AssemblyPart(typeof(Project1.Project1Type).Assembly));

services.AddSingleton(manager);
services.AddMvc();

或者,

global.json文件添加到您的解决方案。

像这样:

{
  "sdk": {
    "version": "2.1.200"
  }
}

请关注此 GitHub 问题以获取更多信息:

于 2018-07-20T21:15:07.497 回答