diff --git a/src/Assets/TestProjects/AppWithLibraryVB/TestApp/Program.vb b/src/Assets/TestProjects/AppWithLibraryVB/TestApp/Program.vb new file mode 100644 index 000000000000..71557d77ec0e --- /dev/null +++ b/src/Assets/TestProjects/AppWithLibraryVB/TestApp/Program.vb @@ -0,0 +1,16 @@ +' Copyright (c) .NET Foundation and contributors. All rights reserved. +' Licensed under the MIT license. See LICENSE file in the project root for full license information. + +Imports System + +Namespace TestApp + + Module Program + + Sub Main(args As String()) + Console.WriteLine(TestLibrary.Helper.GetMessage()) + End Sub + + End Module + +End Namespace diff --git a/src/Assets/TestProjects/AppWithLibraryVB/TestApp/TestApp.vbproj b/src/Assets/TestProjects/AppWithLibraryVB/TestApp/TestApp.vbproj new file mode 100644 index 000000000000..ccedd222162d --- /dev/null +++ b/src/Assets/TestProjects/AppWithLibraryVB/TestApp/TestApp.vbproj @@ -0,0 +1,14 @@ + + + 1.2.3-beta + Test Authors + Test Product + Test AssemblyTitle + Copyright (c) Test Authors + Exe + netcoreapp1.1 + + + + + diff --git a/src/Assets/TestProjects/AppWithLibraryVB/TestLibrary/Helper.vb b/src/Assets/TestProjects/AppWithLibraryVB/TestLibrary/Helper.vb new file mode 100644 index 000000000000..1ab1a359b117 --- /dev/null +++ b/src/Assets/TestProjects/AppWithLibraryVB/TestLibrary/Helper.vb @@ -0,0 +1,18 @@ +' Copyright (c) .NET Foundation and contributors. All rights reserved. +' Licensed under the MIT license. See LICENSE file in the project root for full license information. + +Namespace TestLibrary + + Public Class Helper + + Public Shared Function GetMessage() As String + Return "This string came from the test library!" + End Function + + Public Sub SayHi() + Console.WriteLine("Hello there!") + End Sub + + End Class + +End Namespace diff --git a/src/Assets/TestProjects/AppWithLibraryVB/TestLibrary/TestLibrary.vbproj b/src/Assets/TestProjects/AppWithLibraryVB/TestLibrary/TestLibrary.vbproj new file mode 100644 index 000000000000..ffdef9d77a13 --- /dev/null +++ b/src/Assets/TestProjects/AppWithLibraryVB/TestLibrary/TestLibrary.vbproj @@ -0,0 +1,7 @@ + + + 42.43.44.45-alpha + Library + netstandard1.5 + + diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommon.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommon.targets index 8e857ebd952d..2eadae8977d6 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommon.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommon.targets @@ -165,7 +165,8 @@ Copyright (c) .NET Foundation. All rights reserved. - $(IntermediateOutputPath)$(AssemblyName).xml + $(AssemblyName).xml + $(IntermediateOutputPath)$(AssemblyName).xml diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs index 9f559be395bf..4e96137fdf9b 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs @@ -203,14 +203,20 @@ internal static List GetValuesFromTestLibrary( return itemValues; } - private TestAsset CreateDocumentationFileLibraryAsset(bool? generateDocumentationFile, string documentationFile, [CallerMemberName] string callingMethod = "") + private TestAsset CreateDocumentationFileLibraryAsset(bool? generateDocumentationFile, string documentationFile, string language, [CallerMemberName] string callingMethod = "") { string genDocFileIdentifier = generateDocumentationFile == null ? "null" : generateDocumentationFile.Value.ToString(); string docFileIdentifier = documentationFile == null ? "null" : Path.GetFileName(documentationFile); string identifier = $"-genDoc={genDocFileIdentifier}, docFile={Path.GetFileName(docFileIdentifier)}"; + var testAssetName = "AppWithLibrary"; + if (language != "cs") + { + testAssetName += language.ToUpperInvariant(); + } + var testAsset = _testAssetsManager - .CopyTestAsset("AppWithLibrary", callingMethod, identifier) + .CopyTestAsset(testAssetName, callingMethod, identifier) .WithSource() .WithProjectChanges(project => { @@ -232,10 +238,12 @@ private TestAsset CreateDocumentationFileLibraryAsset(bool? generateDocumentatio return testAsset; } - [Fact] - public void It_creates_a_documentation_file() + [Theory] + [InlineData("cs")] + [InlineData("vb")] + public void It_creates_a_documentation_file(string language) { - var testAsset = CreateDocumentationFileLibraryAsset(true, null); + var testAsset = CreateDocumentationFileLibraryAsset(true, null, language); var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, "TestLibrary"); @@ -257,17 +265,19 @@ public void It_creates_a_documentation_file() new DirectoryInfo(libraryProjectDirectory).Should().OnlyHaveFiles(new[] { - "Helper.cs", - "TestLibrary.csproj" + $"Helper.{language}", + $"TestLibrary.{language}proj" }, SearchOption.TopDirectoryOnly); } [Theory] - [InlineData(true)] - [InlineData(false)] - public void It_allows_us_to_override_the_documentation_file_name(bool setGenerateDocumentationFileProperty) + [InlineData("cs", true)] + [InlineData("cs", false)] + [InlineData("vb", true)] + [InlineData("vb", false)] + public void It_allows_us_to_override_the_documentation_file_name(string language, bool setGenerateDocumentationFileProperty) { - var testAsset = CreateDocumentationFileLibraryAsset(setGenerateDocumentationFileProperty ? (bool?)true : null, "TestLibDoc.xml", "OverrideDocFileName"); + var testAsset = CreateDocumentationFileLibraryAsset(setGenerateDocumentationFileProperty ? (bool?)true : null, "TestLibDoc.xml", language, "OverrideDocFileName"); var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, "TestLibrary"); @@ -289,20 +299,28 @@ public void It_allows_us_to_override_the_documentation_file_name(bool setGenerat // Due to the way the DocumentationFile works, if you specify an unrooted filename, then the documentation file will be generated in that // location relative to the project folder, and then copied to the output folder. - new DirectoryInfo(libraryProjectDirectory).Should().OnlyHaveFiles(new[] + var expectedProjectDirectoryFiles = new List() { - "Helper.cs", - "TestLibrary.csproj", - "TestLibDoc.xml" - }, SearchOption.TopDirectoryOnly); + $"Helper.{language}", + $"TestLibrary.{language}proj" + }; + + // vb uses DocumentationFile relative to the IntermediateOutputPath + if (language != "vb") { + expectedProjectDirectoryFiles.Add("TestLibDoc.xml"); + } + + new DirectoryInfo(libraryProjectDirectory).Should().OnlyHaveFiles(expectedProjectDirectoryFiles, SearchOption.TopDirectoryOnly); } [Theory] - [InlineData(true)] - [InlineData(false)] - public void It_does_not_create_a_documentation_file_if_GenerateDocumentationFile_property_is_false(bool setDocumentationFileProperty) + [InlineData("cs", true)] + [InlineData("cs", false)] + [InlineData("vb", true)] + [InlineData("vb", false)] + public void It_does_not_create_a_documentation_file_if_GenerateDocumentationFile_property_is_false(string language, bool setDocumentationFileProperty) { - var testAsset = CreateDocumentationFileLibraryAsset(false, setDocumentationFileProperty ? "TestLibDoc.xml" : null, "DoesntCreateDocFile"); + var testAsset = CreateDocumentationFileLibraryAsset(false, setDocumentationFileProperty ? "TestLibDoc.xml" : null, language, "DoesntCreateDocFile"); var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, "TestLibrary"); @@ -324,8 +342,8 @@ public void It_does_not_create_a_documentation_file_if_GenerateDocumentationFile // Make sure documentation file isn't generated in project folder either new DirectoryInfo(libraryProjectDirectory).Should().OnlyHaveFiles(new[] { - "Helper.cs", - "TestLibrary.csproj" + $"Helper.{language}", + $"TestLibrary.{language}proj" }, SearchOption.TopDirectoryOnly); } diff --git a/src/Tests/Microsoft.NET.TestFramework/Commands/MSBuildCommand.cs b/src/Tests/Microsoft.NET.TestFramework/Commands/MSBuildCommand.cs index 5cdc60cb8417..1a6fa8aeea11 100644 --- a/src/Tests/Microsoft.NET.TestFramework/Commands/MSBuildCommand.cs +++ b/src/Tests/Microsoft.NET.TestFramework/Commands/MSBuildCommand.cs @@ -51,11 +51,11 @@ internal static string FindProjectFile(ref string projectRootPath, string relati } } - var buildProjectFiles = Directory.GetFiles(projectRootPath, "*.csproj"); + var buildProjectFiles = Directory.GetFiles(projectRootPath, "*.*proj"); if (buildProjectFiles.Length != 1) { - var errorMsg = $"Found {buildProjectFiles.Length} .csproj files under {projectRootPath} instead of just 1."; + var errorMsg = $"Found {buildProjectFiles.Length} project files under {projectRootPath} instead of just 1."; throw new ArgumentException(errorMsg); }