-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enable publishing XML documentation #1062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| using System.Runtime.InteropServices; | ||
| using Newtonsoft.Json; | ||
| using Newtonsoft.Json.Linq; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace Microsoft.NET.Publish.Tests | ||
| { | ||
|
|
@@ -195,6 +196,54 @@ public void It_publishes_projects_with_filter_and_rid() | |
|
|
||
| //TODO: Enable testing the run once dotnet host has the notion of looking up shared packages | ||
| } | ||
|
|
||
|
|
||
| [Theory] | ||
| [MemberData(nameof(PublishDocumentationExpectations))] | ||
|
||
| public void It_publishes_documentation_files(string properties, bool expectAppDocPublished, bool expectLibDocPublished) | ||
| { | ||
| var kitchenSinkAsset = _testAssetsManager | ||
| .CopyTestAsset("KitchenSink") | ||
| .WithSource(); | ||
| kitchenSinkAsset.Restore("TestApp"); | ||
|
|
||
| var publishCommand = new PublishCommand(Stage0MSBuild, Path.Combine(kitchenSinkAsset.TestRoot, "TestApp")); | ||
| var publishResult = publishCommand.Execute(properties); | ||
|
|
||
| publishResult.Should().Pass(); | ||
|
|
||
| var publishDirectory = publishCommand.GetOutputDirectory(); | ||
|
|
||
| if (expectAppDocPublished) | ||
| { | ||
| publishDirectory.Should().HaveFile("TestApp.xml"); | ||
| } | ||
| else | ||
| { | ||
| publishDirectory.Should().NotHaveFile("TestApp.xml"); | ||
| } | ||
|
|
||
| if (expectLibDocPublished) | ||
| { | ||
| publishDirectory.Should().HaveFile("TestLibrary.xml"); | ||
| } | ||
| else | ||
| { | ||
| publishDirectory.Should().NotHaveFile("TestLibrary.xml"); | ||
| } | ||
| } | ||
|
|
||
| public static IEnumerable<object[]> PublishDocumentationExpectations | ||
| { | ||
| get | ||
| { | ||
| yield return new object[] { "/p:GenerateDocumentationFile=true", true, true }; | ||
| yield return new object[] { "/p:GenerateDocumentationFile=true;PublishDocumentationFile=false", false, true }; | ||
| yield return new object[] { "/p:GenerateDocumentationFile=true;PublishProjectReferenceDocumentationFiles=false", true, false }; | ||
| yield return new object[] { "/p:GenerateDocumentationFile=true;PublishDocumentationFiles=false", false, false }; | ||
| } | ||
| } | ||
|
|
||
| private static JObject ReadJson(string path) | ||
| { | ||
| using (JsonTextReader jsonReader = new JsonTextReader(File.OpenText(path))) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rainersigwald @cdmihai @KirillOsenkov @jeffkl - are documentation files the only type of
xmlfiles that can get put in@(ReferenceCopyLocalPaths)? Is there some other way to distinguish what is a P2P reference's doc file?I'm not sure who else would know this, maybe @ericstj @weshaggard @davkean ...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's how the documentation file works:
<DocumentationFile />defined in an individual project@(DocFileItem)here@(DocFileItem)is passed to<Csc />here@(FinalDocFile)here which is a full path to where the file should be copied to@(DocFileItem)is copied to@(FinalDocFile)here<ResolveAssemblyReference />gets passed a list of related file extensions which includes.xml.So technically, the only reason the Doc file shows up in
@(ReferenceCopyLocalPaths)is because it has the same file name without extension as the output assembly. This logic takes the output file name and looks for "related" files by extensions, one of which is.xml. If people were trying to be fancy, they could have their documentation file named something else and it would show up in@(ReferenceCopyLocalPaths).That said, it's probably safe to assume that the only related file ending in
.xmlis the doc file. MSBuild does not currently translate any metadata to these related files that indicate what they were originally.