diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 73677ac18b..f6004d8fdf 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -74,11 +74,11 @@ Copyright (c) .NET Foundation. All rights reserved. - + true - + true diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs index e0f67c61b8..888b8068d2 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs @@ -194,7 +194,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } [Fact] - [InitializeTestProject("AppWithP2PReference", "ClassLibrary")] + [InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")] public async Task Build_WithP2P_CopiesRazorAssembly() { var result = await DotnetMSBuild("Build"); @@ -212,7 +212,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } [Fact] - [InitializeTestProject("SimplePages", "LinkedDir")] + [InitializeTestProject("SimplePages", additionalProjects: "LinkedDir")] public async Task Build_SetsUpEmbeddedResourcesWithLogicalName() { // Arrange @@ -455,6 +455,23 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileDoesNotContain(result, assemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute(\"MVC-2-1\")"); } + [Fact] + [InitializeTestProject("SimpleMvcFSharp", language: "F#")] + public async Task Build_SimpleMvcFSharp_NoopsWithoutFailing() + { + var result = await DotnetMSBuild("Build"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, OutputPath, "SimpleMvcFSharp.dll"); + Assert.FileExists(result, OutputPath, "SimpleMvcFSharp.pdb"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvcFSharp.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvcFSharp.pdb"); + + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvcFSharp.Views.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvcFSharp.Views.pdb"); + } + private static DependencyContext ReadDependencyContext(string depsFilePath) { var reader = new DependencyContextJsonReader(); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/InitializeTestProjectAttribute.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/InitializeTestProjectAttribute.cs index 3b4a69e8a1..86191951f4 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/InitializeTestProjectAttribute.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/InitializeTestProjectAttribute.cs @@ -13,18 +13,20 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests private readonly string _testProjectName; private readonly string _baseDirectory; private readonly string[] _additionalProjects; + private readonly string _language; - public InitializeTestProjectAttribute(string projectName, params string[] additionalProjects) - : this (projectName, projectName, string.Empty, additionalProjects) + public InitializeTestProjectAttribute(string projectName, string language = "C#", params string[] additionalProjects) + : this (projectName, projectName, string.Empty, language, additionalProjects) { } - public InitializeTestProjectAttribute(string originalProjectName, string targetProjectName, string baseDirectory, string[] additionalProjects = null) + public InitializeTestProjectAttribute(string originalProjectName, string targetProjectName, string baseDirectory, string language = "C#", string[] additionalProjects = null) { _originalProjectName = originalProjectName; _testProjectName = targetProjectName; _baseDirectory = baseDirectory; _additionalProjects = additionalProjects ?? Array.Empty(); + _language = language; } public override void Before(MethodInfo methodUnderTest) @@ -34,7 +36,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests throw new InvalidOperationException($"This should be used on a class derived from {typeof(MSBuildIntegrationTestBase)}"); } - MSBuildIntegrationTestBase.Project = ProjectDirectory.Create(_originalProjectName, _testProjectName, _baseDirectory, _additionalProjects); + MSBuildIntegrationTestBase.Project = ProjectDirectory.Create(_originalProjectName, _testProjectName, _baseDirectory, _additionalProjects, _language); MSBuildIntegrationTestBase.TargetFramework = _originalProjectName == "ClassLibrary" ? "netstandard2.0" : "netcoreapp2.0"; } diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ProjectDirectory.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ProjectDirectory.cs index 26ad2a4e69..fcfdd30311 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ProjectDirectory.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ProjectDirectory.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests public bool PreserveWorkingDirectory { get; set; } #endif - public static ProjectDirectory Create(string originalProjectName, string targetProjectName, string baseDirectory, string[] additionalProjects) + public static ProjectDirectory Create(string originalProjectName, string targetProjectName, string baseDirectory, string[] additionalProjects, string language) { var destinationPath = Path.Combine(Path.GetTempPath(), "Razor", baseDirectory, Path.GetRandomFileName()); Directory.CreateDirectory(destinationPath); @@ -53,10 +53,23 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests SetupDirectoryBuildFiles(solutionRoot, binariesRoot, testAppsRoot, projectDestination); } - // Rename the csproj + // Rename the csproj/fsproj + string extension; + if (language.Equals("C#", StringComparison.OrdinalIgnoreCase)) + { + extension = ".csproj"; + } + else if (language.Equals("F#", StringComparison.OrdinalIgnoreCase)) + { + extension = ".fsproj"; + } + else + { + throw new InvalidOperationException($"Language {language} is not supported."); + } var directoryPath = Path.Combine(destinationPath, originalProjectName); - var oldProjectFilePath = Path.Combine(directoryPath, originalProjectName + ".csproj"); - var newProjectFilePath = Path.Combine(directoryPath, targetProjectName + ".csproj"); + var oldProjectFilePath = Path.Combine(directoryPath, originalProjectName + extension); + var newProjectFilePath = Path.Combine(directoryPath, targetProjectName + extension); File.Move(oldProjectFilePath, newProjectFilePath); CopyGlobalJson(solutionRoot, destinationPath); diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs index 22407311fa..3147d26b51 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PublishIntegrationTest.cs @@ -258,7 +258,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } [Fact] - [InitializeTestProject("AppWithP2PReference", "ClassLibrary")] + [InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")] public async Task Publish_WithP2P_AndRazorCompileOnBuild_CopiesRazorAssembly() { var result = await DotnetMSBuild("Publish"); @@ -276,7 +276,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } [Fact] - [InitializeTestProject("AppWithP2PReference", "ClassLibrary")] + [InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")] public async Task Publish_WithP2P_AndRazorCompileOnPublish_CopiesRazorAssembly() { var result = await DotnetMSBuild("Publish"); @@ -292,5 +292,20 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileExists(result, PublishOutputPath, "ClassLibrary.Views.dll"); Assert.FileExists(result, PublishOutputPath, "ClassLibrary.Views.pdb"); } + + [Fact] + [InitializeTestProject("SimpleMvcFSharp", language: "F#")] + public async Task Publish_SimpleMvcFSharp_NoopsWithoutFailing() + { + var result = await DotnetMSBuild("Publish"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, PublishOutputPath, "SimpleMvcFSharp.dll"); + Assert.FileExists(result, PublishOutputPath, "SimpleMvcFSharp.pdb"); + + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvcFSharp.Views.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvcFSharp.Views.pdb"); + } } } diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs index 8ae83dbd39..eb6b764567 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs @@ -273,7 +273,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } [Fact] - [InitializeTestProject("SimpleMvc", "LinkedDir")] + [InitializeTestProject("SimpleMvc", additionalProjects: "LinkedDir")] public async Task RazorGenerate_WorksWithLinkedFiles() { // Arrange @@ -300,7 +300,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } [Fact] - [InitializeTestProject("SimpleMvc", "LinkedDir")] + [InitializeTestProject("SimpleMvc", additionalProjects: "LinkedDir")] public async Task RazorGenerate_PrintsErrorsFromLinkedFiles() { // Arrange diff --git a/test/testapps/SimpleMvcFSharp/Models/ErrorViewModel.fs b/test/testapps/SimpleMvcFSharp/Models/ErrorViewModel.fs new file mode 100644 index 0000000000..111eba32de --- /dev/null +++ b/test/testapps/SimpleMvcFSharp/Models/ErrorViewModel.fs @@ -0,0 +1,8 @@ +namespace SimpleMvcFSharp + +open System + +type ErrorViewModel private () = + member val RequestId : string = null with get, set + + member val ShowRequestId : bool = true with get, set diff --git a/test/testapps/SimpleMvcFSharp/Program.fs b/test/testapps/SimpleMvcFSharp/Program.fs new file mode 100644 index 0000000000..10f99aa34f --- /dev/null +++ b/test/testapps/SimpleMvcFSharp/Program.fs @@ -0,0 +1,11 @@ +namespace SimpleMvcFSharp + +module Program = + let exitCode = 0 + + [] + let main args = + let t = typeof + System.Console.WriteLine(t.FullName) + + exitCode diff --git a/test/testapps/SimpleMvcFSharp/SimpleMvcFSharp.fsproj b/test/testapps/SimpleMvcFSharp/SimpleMvcFSharp.fsproj new file mode 100644 index 0000000000..4e469df733 --- /dev/null +++ b/test/testapps/SimpleMvcFSharp/SimpleMvcFSharp.fsproj @@ -0,0 +1,28 @@ + + + + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ + + + + + + + <_MvcExtensionAssemblyPath>$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\bin\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll + + + + + netcoreapp2.0 + + + + + + + + + + + + diff --git a/test/testapps/SimpleMvcFSharp/Views/Home/About.cshtml b/test/testapps/SimpleMvcFSharp/Views/Home/About.cshtml new file mode 100644 index 0000000000..50476d1fbd --- /dev/null +++ b/test/testapps/SimpleMvcFSharp/Views/Home/About.cshtml @@ -0,0 +1,7 @@ +@{ + ViewData["Title"] = "About"; +} +

@ViewData["Title"].

+

@ViewData["Message"]

+ +

Use this area to provide additional information.

diff --git a/test/testapps/SimpleMvcFSharp/Views/_ViewImports.cshtml b/test/testapps/SimpleMvcFSharp/Views/_ViewImports.cshtml new file mode 100644 index 0000000000..8df2746fd7 --- /dev/null +++ b/test/testapps/SimpleMvcFSharp/Views/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@using SimpleMvcFSharp +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers