|
19 | 19 | using Xunit.Abstractions; |
20 | 20 | using System.Text.RegularExpressions; |
21 | 21 | using System.Collections.Generic; |
| 22 | +using System.Security.Cryptography; |
22 | 23 |
|
23 | 24 | namespace Microsoft.NET.Build.Tests |
24 | 25 | { |
@@ -530,7 +531,7 @@ void Test_inbox_assembly_wins_conflict_resolution(bool useSdkProject, string htt |
530 | 531 |
|
531 | 532 | testProject.PackageReferences.Add(new TestPackageReference("System.Net.Http", httpPackageVersion)); |
532 | 533 |
|
533 | | - testProject.SourceFiles["Program.cs"] = |
| 534 | + testProject.SourceFiles["Program.cs"] = |
534 | 535 | (useAlias ? "extern alias snh;" + Environment.NewLine : "") + |
535 | 536 |
|
536 | 537 | @"using System; |
@@ -850,5 +851,96 @@ public void It_allows_TargetFrameworkVersion_to_be_capitalized() |
850 | 851 | .Should() |
851 | 852 | .Pass(); |
852 | 853 | } |
| 854 | + |
| 855 | + [WindowsOnlyTheory] |
| 856 | + [InlineData("true")] |
| 857 | + [InlineData("false")] |
| 858 | + public void It_places_package_pdb_and_xml_files_in_output_directory_correctly(string enableSymbolsAndXmlFiles) |
| 859 | + { |
| 860 | + var testProject = new TestProject() |
| 861 | + { |
| 862 | + Name = "DesktopUsingPackageWithPdbAndXml", |
| 863 | + TargetFrameworks = ToolsetInfo.CurrentTargetFramework, |
| 864 | + IsExe = true, |
| 865 | + }; |
| 866 | + |
| 867 | + testProject.PackageReferences.Add(new TestPackageReference("Microsoft.Build", "17.3.1")); |
| 868 | + |
| 869 | + // Should copy xml and pdb files to output directory |
| 870 | + testProject.AdditionalProperties.Add("EnableCopySymbolsAndXmlDocsToOutputDir", enableSymbolsAndXmlFiles); |
| 871 | + |
| 872 | + TestAsset testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name); |
| 873 | + |
| 874 | + var buildCommand = new BuildCommand(testAsset); |
| 875 | + |
| 876 | + buildCommand |
| 877 | + .Execute() |
| 878 | + .Should() |
| 879 | + .Pass(); |
| 880 | + |
| 881 | + // By default Xml documentation is copied to the output directory |
| 882 | + var outputDirectory = buildCommand.GetOutputDirectory(testProject.TargetFrameworks); |
| 883 | + |
| 884 | + if (enableSymbolsAndXmlFiles == "true") |
| 885 | + { |
| 886 | + outputDirectory.Should().HaveFile("Microsoft.Build.dll"); |
| 887 | + outputDirectory.Should().HaveFile("Microsoft.Build.pdb"); |
| 888 | + outputDirectory.Should().HaveFile("Microsoft.Build.xml"); |
| 889 | + } else |
| 890 | + { |
| 891 | + outputDirectory.Should().HaveFile("Microsoft.Build.dll"); |
| 892 | + outputDirectory.Should().NotHaveFile("Microsoft.Build.pdb"); |
| 893 | + outputDirectory.Should().NotHaveFile("Microsoft.Build.xml"); |
| 894 | + } |
| 895 | + } |
| 896 | + |
| 897 | + [WindowsOnlyTheory] |
| 898 | + [InlineData("true")] |
| 899 | + [InlineData("false")] |
| 900 | + public void It_places_package_xml_files_in_publish_directory_correctly(string enableSymbolsAndXmlFiles) |
| 901 | + { |
| 902 | + var testProject = new TestProject() |
| 903 | + { |
| 904 | + Name = "DesktopPublishPackageWithPdbAndXml", |
| 905 | + TargetFrameworks = ToolsetInfo.CurrentTargetFramework, |
| 906 | + IsExe = true, |
| 907 | + }; |
| 908 | + |
| 909 | + testProject.PackageReferences.Add(new TestPackageReference("Microsoft.Build", "17.3.1")); |
| 910 | + |
| 911 | + // Should copy xml and pdb files to output directory |
| 912 | + testProject.AdditionalProperties.Add("EnableCopySymbolsAndXmlDocsToOutputDir", enableSymbolsAndXmlFiles); |
| 913 | + |
| 914 | + TestAsset testAsset = _testAssetsManager.CreateTestProject(testProject, testProject.Name); |
| 915 | + |
| 916 | + var buildCommand = new BuildCommand(testAsset); |
| 917 | + |
| 918 | + buildCommand |
| 919 | + .Execute() |
| 920 | + .Should() |
| 921 | + .Pass(); |
| 922 | + |
| 923 | + var publishCommand = new PublishCommand(testAsset); |
| 924 | + publishCommand |
| 925 | + .Execute() |
| 926 | + .Should() |
| 927 | + .Pass(); |
| 928 | + |
| 929 | + // By default Xml documentation is copied to the output directory |
| 930 | + var publishDirectory = publishCommand.GetOutputDirectory(testProject.TargetFrameworks); |
| 931 | + |
| 932 | + if (enableSymbolsAndXmlFiles == "true") |
| 933 | + { |
| 934 | + publishDirectory.Should().HaveFile("Microsoft.Build.dll"); |
| 935 | + publishDirectory.Should().HaveFile("Microsoft.Build.pdb"); |
| 936 | + publishDirectory.Should().HaveFile("Microsoft.Build.xml"); |
| 937 | + } |
| 938 | + else |
| 939 | + { |
| 940 | + publishDirectory.Should().HaveFile("Microsoft.Build.dll"); |
| 941 | + publishDirectory.Should().NotHaveFile("Microsoft.Build.pdb"); |
| 942 | + publishDirectory.Should().NotHaveFile("Microsoft.Build.xml"); |
| 943 | + } |
| 944 | + } |
853 | 945 | } |
854 | 946 | } |
0 commit comments