'swagger documentation xml file not found on azure

I have a class MyClass which uses a class from another class ClassCommon. For swagger, I used xml comment like below:

MyClass

        /// <summary>
        /// Gets or Sets Property X.
        /// </summary>
        [JsonProperty(PropertyName = "x")]
        public ClassCommon X { get; set; }

ClassCommon

public class ClassCommon{
        /// <summary>
        /// Gets or sets y.
        /// </summary>
        /// <example>foo</example>
        [JsonProperty(PropertyName = "y")]
        public string Y { get; set; }
}

I have set

<GenerateDocumentationFile>true</GenerateDocumentationFile>

in ClassCommon.csproj file.

I also modified startup.cs to add:

                    // Set the comments path for the Swagger JSON and UI.
                    var xmlFiles = new string[] { $"{Assembly.GetExecutingAssembly().GetName().Name}", $"{ClassCommon}" };
                    foreach (var xmlFile in xmlFiles)
                    {
                        var xmlPath = Path.Combine(AppContext.BaseDirectory, $"{xmlFile}.xml");
                        c.IncludeXmlComments(xmlPath);
                    }

This builds successfully after I add ClassCommon as a dependency to MyClass. Everything works fine when I run locally. But when I deploy it to Azure, swagger complains

Could not find file 'C:\home\site\wwwroot\ClassCommon.xml'.

I stuck for one day yet have no clue why this is the case. Can someone shed any light on me?

Thanks a bunch!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source