Skip to content

Commit

Permalink
Publish XML documentaiton by default and enable opting out of publisi…
Browse files Browse the repository at this point in the history
…ng all xml documentation.
  • Loading branch information
dasMulli committed Apr 4, 2017
1 parent 8f08f12 commit 1afbf31
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<ResolvedFileToPublish Include="@(ResolvedAssembliesToPublish)">
<RelativePath>%(ResolvedAssembliesToPublish.DestinationSubPath)</RelativePath>
</ResolvedFileToPublish>

<!-- Copy the xml documentation (if enabled) -->
<ResolvedFileToPublish Include="@(FinalDocFile)"
Condition="'$(PublishDocumentationFile)' == 'true'">
<RelativePath>@(FinalDocFile->'%(Filename)%(Extension)')</RelativePath>
</ResolvedFileToPublish>
</ItemGroup>

</Target>
Expand All @@ -211,7 +217,9 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- TODO perform any preprocess transforms on the files -->

<ItemGroup>
<ResolvedAssembliesToPublish Include="@(ReferenceCopyLocalPaths)" Exclude="@(ResolvedAssembliesToPublish)">
<ResolvedAssembliesToPublish Include="@(ReferenceCopyLocalPaths)"
Exclude="@(ResolvedAssembliesToPublish)"
Condition="'$(PublishProjectReferenceDocumentationFiles)' == 'true' or '%(Extension)' != '.xml'">
<DestinationSubPath>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(Filename)%(Extension)</DestinationSubPath>
</ResolvedAssembliesToPublish>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<DocumentationFile />
</PropertyGroup>

<PropertyGroup>
<PublishDocumentationFiles Condition="'$(PublishDocumentationFiles)' == ''">true</PublishDocumentationFiles>
<PublishDocumentationFile Condition="'$(PublishDocumentationFile)' == '' and '$(PublishDocumentationFiles)' == 'true'">true</PublishDocumentationFile>
<PublishProjectReferenceDocumentationFiles Condition="'$(PublishProjectReferenceDocumentationFiles)' == '' and '$(PublishDocumentationFiles)' == 'true'">true</PublishProjectReferenceDocumentationFiles>
</PropertyGroup>

<!-- Add a project capability so that the project properties in the IDE can show the option to generate an XML documentation file without specifying the filename -->
<ItemGroup>
<ProjectCapability Include="GenerateDocumentationFile" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;

namespace Microsoft.NET.Publish.Tests
{
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit 1afbf31

Please sign in to comment.