-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Enable publishing XML documentation #1062
Enable publishing XML documentation #1062
Conversation
@@ -137,6 +137,11 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
<DocumentationFile /> | |||
</PropertyGroup> | |||
|
|||
<PropertyGroup Condition="'$(PublishDocumentationFile)' == ''"> | |||
<PublishDocumentationFile Condition="'$(GenerateDocumentationFile)' == 'true'">true</PublishDocumentationFile> |
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.
I think it should be false by default regardless. Apps can opt-in and packages that depend on it (like swagger) could even carry props to turn it on. It's consistent with the v1 behavior and it's pay-for-play in terms of publish size.
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.
The situation currently is: if you haven an app and library as ProjectReference
, the documentation file of the library is published with the app, but not the app's own documentation.
That's the main reason why i chose it to be on by default.
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.
if you haven an app and library as ProjectReference, the documentation file of the library is published with the app
Can you add a test for this? I think using the KitchenSink
project would be the easiest. You could probably change your two tests below to use that TestAsset, and be able to test all these scenarios pretty easy.
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.
The situation currently is: [...]
I see. In that case, I think we want this new opt-out to disable that behavior for project refs too.
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.
think we want this new opt-out to disable that behavior for project refs too.
I think so. I'm thinking about renaming it to PublishDocumentationFiles
(plural) to:
- Control adding
@(FinalDocFile)
to@(ResolvedFileToPublish)
- Filter out xml files
returned from thefrom project referencesResolvePublishAssemblies
task (maybe add a task parameter although it doesn't really seem to fit in there).
Thoughts?
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.
Makes sense.
58f512c
to
3c6e14a
Compare
Updated based on discussion to enable opting out of publishing documentation of p2p references. |
3c6e14a
to
f7b2702
Compare
…ng all xml documentation.
f7b2702
to
1afbf31
Compare
<ResolvedAssembliesToPublish Include="@(ReferenceCopyLocalPaths)" Exclude="@(ResolvedAssembliesToPublish)"> | ||
<ResolvedAssembliesToPublish Include="@(ReferenceCopyLocalPaths)" | ||
Exclude="@(ResolvedAssembliesToPublish)" | ||
Condition="'$(PublishProjectReferenceDocumentationFiles)' == 'true' or '%(Extension)' != '.xml'"> |
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 xml
files 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:
- It starts life as a property
<DocumentationFile />
defined in an individual project - It gets added to an item group
@(DocFileItem)
here @(DocFileItem)
is passed to<Csc />
here- It is added an item group
@(FinalDocFile)
here which is a full path to where the file should be copied to - The
@(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 .xml
is the doc file. MSBuild does not currently translate any metadata to these related files that indicate what they were originally.
I'm having doubts about the naming of the |
|
||
|
||
[Theory] | ||
[MemberData(nameof(PublishDocumentationExpectations))] |
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.
Why use member data here and inlinedata in the other? I particularly prefer inlinedata in this case.
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.
Rule of thumb.. 4x3 arguments was more than 2x2.
But you're right, even other tests use InlineData more. I'll change it.
…sDocumentationFiles and added tests for publishing with references to assemblies.
efdbc49
to
56d9419
Compare
@dotnet-bot test OSX10.12 Release |
@eerhardt Not yet. IT updated that other groups are seeing symptoms too. |
Thanks for the PR @dasMulli |
I heard performance being mentioned as an issue regarding turning on these flags. Looks like both of these options are turned on by default which is great. |
@livarcocc Hi, is this fix available in SDK 1.0.4?. I'm using 1.0.4 SDK, however, dotnet publish doesn't seem to output the XML documentation for my project. I have Am I missing something?, thanks. /cc @dasMulli |
@NETESudarshan this is part of the upcoming 2.0.0 tooling which is currently in preview. |
@dasMulli Ok, thanks. Is there a quick way to find out the milestone or target release for an issue here? |
@dasMulli Did this make it into the 2.0 release in the end? |
@freeranger yes.. are you experiencing problems with it? (if so and it takes a bit longer to explain better create a new issue) |
@freeranger this should work when building with the 2.0.0 SDK for .net core 1.0/1.1 (there are some issues with the dependency model for asp.net though) |
Thanks @dasMulli, I'll give it a go. Can you point me to some docs on the new way of doing it? |
…0191031.6 (dotnet#1062) - Microsoft.AspNetCore.Analyzers - 5.0.0-alpha1.19531.6 - Microsoft.AspNetCore.Mvc.Api.Analyzers - 5.0.0-alpha1.19531.6 - Microsoft.AspNetCore.Mvc.Analyzers - 5.0.0-alpha1.19531.6 - Microsoft.AspNetCore.Components.Analyzers - 5.0.0-alpha1.19531.6
…Files) to false In `PerformanceTest`, I've been seeing this MSBuild target take time on macOS: _ComputeResolvedCopyLocalPublishAssets 183ms This is in a build with no changes, and the target doesn't actually do anything besides emit an `<ItemGroup/>`: https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L708-L726 In application projects, we should be able to set `$(PublishReferencesDocumentationFiles)` to `false`, so this target will skip most of its work. I have not found any proper documentation for `$(PublishReferencesDocumentationFiles)`, but I believe the intention is that `.xml` documentation files are copied to the build output from all dependencies. We shouldn't need this behavior for an Android application. See: dotnet/sdk#1062 I also modified `PerformanceTest` to remove some additional time allowed for .NET 6 builds.
…Files) to false In `PerformanceTest`, I've been seeing the `_ComputeResolvedCopyLocalPublishAssets` MSBuild target from the dotnet/sdk take time on our CI on macOS: _ComputeResolvedCopyLocalPublishAssets 183ms This is in a build with no changes, and the target doesn't actually do anything besides emit an `<ItemGroup/>`: https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L708-L726 In application projects, we should be able to set `$(PublishReferencesDocumentationFiles)` to `false`, so this target will skip most of its work. I have not found any proper documentation for `$(PublishReferencesDocumentationFiles)`, but I believe the intention is that `.xml` documentation files are copied to the build output from all dependencies. We shouldn't need this behavior for an Android application. See: dotnet/sdk#1062 `_ComputeResolvedCopyLocalPublishAssets` now shows 0ms, so this seems to save ~183ms for all .NET 6 app builds.
…Files) to false In `PerformanceTest`, I've been seeing the `_ComputeResolvedCopyLocalPublishAssets` MSBuild target from the dotnet/sdk take time on our CI on macOS: _ComputeResolvedCopyLocalPublishAssets 183ms This is in a build with no changes, and the target doesn't actually do anything besides emit an `<ItemGroup/>`: https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L708-L726 In application projects, we should be able to set `$(PublishReferencesDocumentationFiles)` to `false`, so this target will skip most of its work. I have not found any proper documentation for `$(PublishReferencesDocumentationFiles)`, but I believe the intention is that `.xml` documentation files are copied to the build output from all dependencies. We shouldn't need this behavior for an Android application. See: dotnet/sdk#1062 `_ComputeResolvedCopyLocalPublishAssets` now shows 0ms, so this seems to save ~183ms for all .NET 6 app builds.
…Files) to false In `PerformanceTest`, I've been seeing the `_ComputeResolvedCopyLocalPublishAssets` MSBuild target from the dotnet/sdk take time on our CI on macOS: _ComputeResolvedCopyLocalPublishAssets 183ms This is in a build with no changes, and the target doesn't actually do anything besides emit an `<ItemGroup/>`: https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L708-L726 In application projects, we should be able to set `$(PublishReferencesDocumentationFiles)` to `false`, so this target will skip most of its work. I have not found any proper documentation for `$(PublishReferencesDocumentationFiles)`, but I believe the intention is that `.xml` documentation files are copied to the build output from all dependencies. We shouldn't need this behavior for an Android application. See: dotnet/sdk#1062 `_ComputeResolvedCopyLocalPublishAssets` now shows 0ms, so this seems to save ~183ms for all .NET 6 app builds.
In `PerformanceTest`, I've been seeing the `_ComputeResolvedCopyLocalPublishAssets` MSBuild target from the dotnet/sdk take time on our CI on macOS: _ComputeResolvedCopyLocalPublishAssets 183ms This is in a build with no changes, and the target doesn't actually do anything besides emit an `<ItemGroup/>`: https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L708-L726 In application projects, we should be able to set `$(PublishReferencesDocumentationFiles)` to `false`, so this target will skip most of its work. I have not found any proper documentation for `$(PublishReferencesDocumentationFiles)`, but I believe the intention is that `.xml` documentation files are copied to the build output from all dependencies. We shouldn't need this behavior for an Android application. See: dotnet/sdk#1062 `_ComputeResolvedCopyLocalPublishAssets` now shows 0ms, so this seems to save ~183ms for all .NET 6 app builds.
…se (#5380) In `PerformanceTest`, I've been seeing the `_ComputeResolvedCopyLocalPublishAssets` MSBuild target from the dotnet/sdk take time on our CI on macOS: _ComputeResolvedCopyLocalPublishAssets 183ms This is in a build with no changes, and the target doesn't actually do anything besides emit an `<ItemGroup/>`: https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L708-L726 In application projects, we should be able to set `$(PublishReferencesDocumentationFiles)` to `false`, so this target will skip most of its work. I have not found any proper documentation for `$(PublishReferencesDocumentationFiles)`, but I believe the intention is that `.xml` documentation files are copied to the build output from all dependencies. We shouldn't need this behavior for an Android application. See: dotnet/sdk#1062 `_ComputeResolvedCopyLocalPublishAssets` now shows 0ms, so this seems to save ~183ms for all .NET 6 app builds.
Fixes #795 by publishing the XML documentation by default when documentation generation is enabled unless
PublishDocumentationFile
is set tofalse
.Edit:
Note that documentation files of project references are already included in the published output.
Update:
PublishDocumentationFiles
can be set tofalse
to opt out of publishing own documentation and documentation of project references. (SetsPublishDocumentationFile
andPublishProjectReferenceDocumentationFiles
to false)PublishDocumentationFile
can be set individually to opt out of publishing own documentation file.PublishReferencesDocumentationFiles
can be set individually to opt out of publishing documentation files of project and assembly references.cc @eerhardt @nguerrera