繁体   English   中英

如何转换XML配置的预构建?

[英]How to transform XML configuration pre-build?

我有一个解决方案:

Solution1
--ConfigProject
----AppManifest.xml
----ServiceManifest.xml
--Project1
--Project2

ServiceManifest.xml如下所示:

<ServiceManifest>
        ...............
  <Resources>
    <Endpoints>
      <!-- This endpoint is used by the communication listener to obtain the port on which to 
           listen. Please note that if your service is partitioned, this port is shared with 
           replicas of different partitions that are placed in your code. -->
      <Endpoint Protocol="https" Name="ServiceEndpoint" Type="Input" />
    </Endpoints>
  </Resources>
</ServiceManifest>

在不依赖c#代码的情况下,是否可以添加一个预构建步骤,以根据AppManifest.xml文件中的设置转换ServiceManifest文件中的Resources部分?

您可以将服务清单描述如下:

<ServiceManifestImport>
    <ServiceManifestRef ServiceManifestName="Stateless1Pkg" ServiceManifestVersion="1.0.0" />
    <ConfigOverrides />
    <ResourceOverrides>
        <Endpoints>
            <Endpoint Name="ServiceEndpoint" Port="[Port]" Protocol="[Protocol]" Type="[Type]" />
            <Endpoint Name="ServiceEndpoint1" Port="[Port1]" Protocol="[Protocol1] "/>
        </Endpoints>
    </ResourceOverrides>
    <Policies>
       <EndpointBindingPolicy CertificateRef="TestCert1" EndpointRef="ServiceEndpoint"/>
    </Policies>
</ServiceManifestImport>

现在,您可以在ApplicationManifest中应用参数。 如果需要,可以为它们添加一个默认值。

<Parameters>
   <Parameter Name="Port" DefaultValue="" />
   <Parameter Name="Protocol" DefaultValue="" />
   <Parameter Name="Type" DefaultValue="" />
   <Parameter Name="Port1" DefaultValue="" />
   <Parameter Name="Protocol1" DefaultValue="" />
</Parameters>

您可以使用自己的自定义ApplicationParameters文件覆盖这些参数(例如Local1.1Node.xml和Local.5Node.xml)。 另一种选择是在发布过程中按每个Powershell插入参数:

PS C:\> New-ServiceFabricApplication -ApplicationName fabric:/myapp -ApplicationTypeName "AppType" -ApplicationTypeVersion "1.0.0" -ApplicationParameter @{Port='1001'; Protocol='https'; Type='Input'; Port1='2001'; Protocol='http'}

有关更多详细信息,请访问: https : //docs.microsoft.com/en-us/azure/service-fabric/service-fabric-service-manifest-resources

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM