【问题标题】:Can you use project.json in an azure service fabric project?可以在 Azure 服务结构项目中使用 project.json 吗?
【发布时间】:2016-07-25 17:34:32
【问题描述】:

我正在尝试使用 project.json 来更轻松地在 Service Fabric 项目中管理包。

但是它失败了,我认为这是由于服务中没有包含 ServiceFabricServiceModel.dll。我可以在 C:\Users\nick.nuget\packages\Microsoft.ServiceFabric.Actors\2.0.135\lib\net45 的 nuget 包中看到 dll,但 nuspec 文件没有引用它。

尝试部署时出现不少错误。

例如

Exception thrown during async task execution
System.IO.FileNotFoundException: Could not load file or assembly 'ServiceFabricServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'ServiceFabricServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at Microsoft.ServiceFabric.Services.Common.FabricServiceConfigSection.Initialize()
   at Microsoft.ServiceFabric.Services.Remoting.FabricTransport.FabricTransportServiceRemotingProviderAttribute.CreateServiceRemotingListener(ServiceContext serviceContext, IService service)
   at Microsoft.ServiceFabric.Services.Runtime.StatefulServiceReplicaAdapter.<OpenCommunicationListenersAsync>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.ServiceFabric.Services.Runtime.StatefulServiceReplicaAdapter.<System.Fabric.IStatefulServiceReplica.ChangeRoleAsync>d__5.MoveNext()

=== Pre-bind state information ===
LOG: DisplayName = ServiceFabricServiceModel, Version=5.0.0.0,     Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/SfDevCluster/Data/_App/_Node_1/SceneSkopePlatformType_App0/ServiceRegistrationServicePkg.Code.1.1.13 (2016-04-05 16.10.16Z)/
LOG: Initial PrivatePath = NULL
Calling assembly : Microsoft.ServiceFabric.Services, Version=5.0.0.0,         Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\SfDevCluster\Data\_App\_Node_1\SceneSkopePlatformType_App0\ServiceRegistrationServicePkg.Code.1.1.13 (2016-04-05 16.10.16Z)\ServiceRegistrationService.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: ServiceFabricServiceModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

【问题讨论】:

  • 您是否尝试从非服务结构应用程序访问 Service Fabric Reliable Actor/Service?
  • 不 - 我正在尝试编写一个服务结构参与者,但作为一个新的 dotnet 项目而不是 csproj。这可能与 project.json 明显消失不再相关
  • 在stackoverflow.com/questions/35656598/…链接上查看Azhar的答案
  • 那条评论是关于 x64 的。这个问题是关于使用 project.json 而不是 csproj

标签: azure asp.net-core azure-service-fabric


【解决方案1】:

这是 dotnet cli 如何处理 nuget 包中未列出的程序集的重大更改。对于“旧式”项目,VS2015 将此程序集复制到项目输出,但 dotnet cli 不会。

在修复之前,您可以包装程序集或在发布后步骤中将其复制到输出中。 程序集下载到: %userprofile%.nuget\packages\Microsoft.ServiceFabric.Services\2.0.135\lib\net45

【讨论】:

  • 我尝试追踪问题出在哪里,很可能是 nuget 包而不是 dotnet。 .nu​​spec 文件仅列出一个参考文件 Microsoft.ServiceFabric.Services.dll。 .nu​​spec 文件中缺少 ServiceFabricServiceModels.dll。如果您查看类似的包Microsoft.ServiceFabric.Data,则会列出两个 dll 文件,它们会被 dotnet 复制到 bin 文件夹中。我检查了版本 2.0.217。这是一个错误吗?
  • 您能否提供一个示例,说明如何在文件修复之前发布文件?
  • 在docs 中找到了答案。在project.json 添加部分"scripts": { "postpublish": [ "xcopy ..\\pathtofile %publish:OutputPath%" ] }
  • 这里是确切的命令: "scripts": {"postpublish": [ "xcopy ..\\packages\\Microsoft.ServiceFabric.Services.2.0.217\\lib\\net45\\ServiceFabricServiceModel .dll %publish:OutputPath%" ] }
【解决方案2】:

MSFT 在最新的 nuget 包版本 2.1.150 中解决了这个问题

【讨论】:

    猜你喜欢
    • 2016-10-28
    • 1970-01-01
    • 2020-10-23
    • 2016-12-04
    • 2019-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-23
    相关资源
    最近更新 更多