microsoft / service-fabric

Service Fabric is a distributed systems platform for packaging, deploying, and managing stateless and stateful distributed applications and containers at large scale.
https://docs.microsoft.com/en-us/azure/service-fabric/
MIT License
3.03k stars 401 forks source link

XML comments moving on build #303

Open cs-un opened 5 years ago

cs-un commented 5 years ago

Custom XML comments move when you build your service fabric application.

Environment: Service Fabric SDK 3.1.2.176.9494, Visual Studio 15.9.7 Enterprise

Steps to reproduce: Create new service fabric stateless asp.net core web api project

Modify ApplicationManifest.xml and put comments "Test comment 1" and "Test Comment 2" as in code below.

Building the project makes the comments switch places.


<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="Application1Type" ApplicationTypeVersion="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
  <Parameters>
    <!-- Test comment 1 -->
    <!-- Test comment 2 -->
    <Parameter Name="Web1_ASPNETCORE_ENVIRONMENT" DefaultValue="" />
    <Parameter Name="Web1_InstanceCount" DefaultValue="-1" />
  </Parameters>
  <!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion
       should match the Name and Version attributes of the ServiceManifest element defined in the
       ServiceManifest.xml file. -->
  <ServiceManifestImport>
    <ServiceManifestRef ServiceManifestName="Web1Pkg" ServiceManifestVersion="1.0.0" />
    <ConfigOverrides />
    <EnvironmentOverrides CodePackageRef="code">
      <EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[Web1_ASPNETCORE_ENVIRONMENT]" />
    </EnvironmentOverrides>
  </ServiceManifestImport>
  <DefaultServices>
    <!-- The section below creates instances of service types, when an instance of this
         application type is created. You can also create one or more instances of service type using the
         ServiceFabric PowerShell module.

         The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. -->
    <Service Name="Web1" ServicePackageActivationMode="ExclusiveProcess">
      <StatelessService ServiceTypeName="Web1Type" InstanceCount="[Web1_InstanceCount]">
        <SingletonPartition />
      </StatelessService>
    </Service>
  </DefaultServices>
</ApplicationManifest>```
NCarlsonMSFT commented 5 years ago

By default on build VS runs the Service Fabric SDK's AppManifestCleanupUtil.exe against the Application Manifest. This is a tool that can remove stale references to services that have been removed and handle injecting the needed information for Actors. If you application manifest is stable, and/or you are willing to take on maintaining the manifest your self, you can disable this behavior by setting UpdateServiceFabricApplicationManifestEnabled to False.

ayrtonmassey commented 6 days ago

@NCarlsonMSFT we're experiencing this issue in one of our Service Fabric projects. What is the reason for this utility re-ordering / rearranging comments? Is there a way to prevent the tool from doing this, without disabling it entirely?

NCarlsonMSFT commented 5 days ago

Sorry @ayrtonmassey the AppManifestCleanupUtil tool is owned by the SF SDK not the VS Tools, so the VS tools can only control whether or not the it is run.