|
13 | 13 | using System.Runtime.InteropServices; |
14 | 14 | using Newtonsoft.Json; |
15 | 15 | using Newtonsoft.Json.Linq; |
| 16 | +using System.Collections.Generic; |
| 17 | +using Microsoft.NET.TestFramework.ProjectConstruction; |
16 | 18 |
|
17 | 19 | namespace Microsoft.NET.Publish.Tests |
18 | 20 | { |
@@ -189,6 +191,98 @@ public void It_publishes_projects_with_filter_and_rid() |
189 | 191 |
|
190 | 192 | //TODO: Enable testing the run once dotnet host has the notion of looking up shared packages |
191 | 193 | } |
| 194 | + |
| 195 | + |
| 196 | + [Theory] |
| 197 | + [InlineData("GenerateDocumentationFile=true", true, true)] |
| 198 | + [InlineData("GenerateDocumentationFile=true;PublishDocumentationFile=false", false, true)] |
| 199 | + [InlineData("GenerateDocumentationFile=true;PublishReferencesDocumentationFiles=false", true, false)] |
| 200 | + [InlineData("GenerateDocumentationFile=true;PublishDocumentationFiles=false", false, false)] |
| 201 | + public void It_publishes_documentation_files(string properties, bool expectAppDocPublished, bool expectLibProjectDocPublished) |
| 202 | + { |
| 203 | + var kitchenSinkAsset = _testAssetsManager |
| 204 | + .CopyTestAsset("KitchenSink", identifier: $"{expectAppDocPublished}_{expectLibProjectDocPublished}") |
| 205 | + .WithSource(); |
| 206 | + kitchenSinkAsset.Restore("TestApp"); |
| 207 | + |
| 208 | + var publishCommand = new PublishCommand(Stage0MSBuild, Path.Combine(kitchenSinkAsset.TestRoot, "TestApp")); |
| 209 | + var publishResult = publishCommand.Execute("/p:" + properties); |
| 210 | + |
| 211 | + publishResult.Should().Pass(); |
| 212 | + |
| 213 | + var publishDirectory = publishCommand.GetOutputDirectory(); |
| 214 | + |
| 215 | + if (expectAppDocPublished) |
| 216 | + { |
| 217 | + publishDirectory.Should().HaveFile("TestApp.xml"); |
| 218 | + } |
| 219 | + else |
| 220 | + { |
| 221 | + publishDirectory.Should().NotHaveFile("TestApp.xml"); |
| 222 | + } |
| 223 | + |
| 224 | + if (expectLibProjectDocPublished) |
| 225 | + { |
| 226 | + publishDirectory.Should().HaveFile("TestLibrary.xml"); |
| 227 | + } |
| 228 | + else |
| 229 | + { |
| 230 | + publishDirectory.Should().NotHaveFile("TestLibrary.xml"); |
| 231 | + } |
| 232 | + } |
| 233 | + |
| 234 | + [Theory] |
| 235 | + [InlineData("PublishReferencesDocumentationFiles=false", false)] |
| 236 | + [InlineData("PublishReferencesDocumentationFiles=true", true)] |
| 237 | + public void It_publishes_referenced_assembly_documentation(string property, bool expectAssemblyDocumentationFilePublished) |
| 238 | + { |
| 239 | + var identifier = property.Replace("=", ""); |
| 240 | + |
| 241 | + var libProject = new TestProject |
| 242 | + { |
| 243 | + Name = "NetStdLib", |
| 244 | + IsSdkProject = true, |
| 245 | + TargetFrameworks = "netstandard1.0" |
| 246 | + }; |
| 247 | + |
| 248 | + var libAsset = _testAssetsManager.CreateTestProject(libProject, identifier: identifier) |
| 249 | + .Restore("NetStdLib"); |
| 250 | + |
| 251 | + var libPublishCommand = new PublishCommand(Stage0MSBuild, Path.Combine(libAsset.TestRoot, "NetStdLib")); |
| 252 | + var libPublishResult = libPublishCommand.Execute("/t:Publish", "/p:GenerateDocumentationFile=true"); |
| 253 | + libPublishResult.Should().Pass(); |
| 254 | + var publishedLibPath = Path.Combine(libPublishCommand.GetOutputDirectory("netstandard1.0").FullName, "NetStdLib.dll"); |
| 255 | + |
| 256 | + var appProject = new TestProject |
| 257 | + { |
| 258 | + Name = "TestApp", |
| 259 | + IsSdkProject = true, |
| 260 | + IsExe = true, |
| 261 | + TargetFrameworks = "netcoreapp2.0", |
| 262 | + RuntimeFrameworkVersion = RepoInfo.NetCoreApp20Version, |
| 263 | + References = { publishedLibPath } |
| 264 | + }; |
| 265 | + |
| 266 | + var appAsset = _testAssetsManager.CreateTestProject(appProject, identifier: identifier); |
| 267 | + var appSourcePath = Path.Combine(appAsset.TestRoot, "TestApp"); |
| 268 | + |
| 269 | + new RestoreCommand(Stage0MSBuild, appSourcePath).Execute().Should().Pass(); |
| 270 | + var appPublishCommand = new PublishCommand(Stage0MSBuild, appSourcePath); |
| 271 | + var appPublishResult = appPublishCommand.Execute("/p:" + property); |
| 272 | + appPublishResult.Should().Pass(); |
| 273 | + |
| 274 | + var appPublishDirectory = appPublishCommand.GetOutputDirectory("netcoreapp2.0"); |
| 275 | + |
| 276 | + if (expectAssemblyDocumentationFilePublished) |
| 277 | + { |
| 278 | + appPublishDirectory.Should().HaveFile("NetStdLib.xml"); |
| 279 | + } |
| 280 | + else |
| 281 | + { |
| 282 | + appPublishDirectory.Should().NotHaveFile("NetStdLib.xml"); |
| 283 | + } |
| 284 | + } |
| 285 | + |
192 | 286 | private static JObject ReadJson(string path) |
193 | 287 | { |
194 | 288 | using (JsonTextReader jsonReader = new JsonTextReader(File.OpenText(path))) |
|
0 commit comments