Noop Razor Sdk for F# projects
This commit is contained in:
parent
5504374125
commit
6d9df1ef33
|
|
@ -74,11 +74,11 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<!--
|
<!--
|
||||||
Default values for properties that affect Razor targets to the standard build lifecycle.
|
Default values for properties that affect Razor targets to the standard build lifecycle.
|
||||||
-->
|
-->
|
||||||
<PropertyGroup Condition="'$(RazorCompileOnBuild)'==''">
|
<PropertyGroup Condition="'$(RazorCompileOnBuild)'=='' AND '$(Language)'=='C#'">
|
||||||
<RazorCompileOnBuild>true</RazorCompileOnBuild>
|
<RazorCompileOnBuild>true</RazorCompileOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(RazorCompileOnPublish)'==''">
|
<PropertyGroup Condition="'$(RazorCompileOnPublish)'=='' AND '$(Language)'=='C#'">
|
||||||
<!-- Always compile on publish by default if we're compiling on build -->
|
<!-- Always compile on publish by default if we're compiling on build -->
|
||||||
<RazorCompileOnPublish Condition="'$(RazorCompileOnBuild)'=='true'">true</RazorCompileOnPublish>
|
<RazorCompileOnPublish Condition="'$(RazorCompileOnBuild)'=='true'">true</RazorCompileOnPublish>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[InitializeTestProject("AppWithP2PReference", "ClassLibrary")]
|
[InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")]
|
||||||
public async Task Build_WithP2P_CopiesRazorAssembly()
|
public async Task Build_WithP2P_CopiesRazorAssembly()
|
||||||
{
|
{
|
||||||
var result = await DotnetMSBuild("Build");
|
var result = await DotnetMSBuild("Build");
|
||||||
|
|
@ -212,7 +212,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[InitializeTestProject("SimplePages", "LinkedDir")]
|
[InitializeTestProject("SimplePages", additionalProjects: "LinkedDir")]
|
||||||
public async Task Build_SetsUpEmbeddedResourcesWithLogicalName()
|
public async Task Build_SetsUpEmbeddedResourcesWithLogicalName()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -455,6 +455,23 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
Assert.FileDoesNotContain(result, assemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute(\"MVC-2-1\")");
|
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)
|
private static DependencyContext ReadDependencyContext(string depsFilePath)
|
||||||
{
|
{
|
||||||
var reader = new DependencyContextJsonReader();
|
var reader = new DependencyContextJsonReader();
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,20 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
private readonly string _testProjectName;
|
private readonly string _testProjectName;
|
||||||
private readonly string _baseDirectory;
|
private readonly string _baseDirectory;
|
||||||
private readonly string[] _additionalProjects;
|
private readonly string[] _additionalProjects;
|
||||||
|
private readonly string _language;
|
||||||
|
|
||||||
public InitializeTestProjectAttribute(string projectName, params string[] additionalProjects)
|
public InitializeTestProjectAttribute(string projectName, string language = "C#", params string[] additionalProjects)
|
||||||
: this (projectName, projectName, string.Empty, 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;
|
_originalProjectName = originalProjectName;
|
||||||
_testProjectName = targetProjectName;
|
_testProjectName = targetProjectName;
|
||||||
_baseDirectory = baseDirectory;
|
_baseDirectory = baseDirectory;
|
||||||
_additionalProjects = additionalProjects ?? Array.Empty<string>();
|
_additionalProjects = additionalProjects ?? Array.Empty<string>();
|
||||||
|
_language = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Before(MethodInfo methodUnderTest)
|
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)}");
|
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";
|
MSBuildIntegrationTestBase.TargetFramework = _originalProjectName == "ClassLibrary" ? "netstandard2.0" : "netcoreapp2.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
public bool PreserveWorkingDirectory { get; set; }
|
public bool PreserveWorkingDirectory { get; set; }
|
||||||
#endif
|
#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());
|
var destinationPath = Path.Combine(Path.GetTempPath(), "Razor", baseDirectory, Path.GetRandomFileName());
|
||||||
Directory.CreateDirectory(destinationPath);
|
Directory.CreateDirectory(destinationPath);
|
||||||
|
|
@ -53,10 +53,23 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
SetupDirectoryBuildFiles(solutionRoot, binariesRoot, testAppsRoot, projectDestination);
|
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 directoryPath = Path.Combine(destinationPath, originalProjectName);
|
||||||
var oldProjectFilePath = Path.Combine(directoryPath, originalProjectName + ".csproj");
|
var oldProjectFilePath = Path.Combine(directoryPath, originalProjectName + extension);
|
||||||
var newProjectFilePath = Path.Combine(directoryPath, targetProjectName + ".csproj");
|
var newProjectFilePath = Path.Combine(directoryPath, targetProjectName + extension);
|
||||||
File.Move(oldProjectFilePath, newProjectFilePath);
|
File.Move(oldProjectFilePath, newProjectFilePath);
|
||||||
|
|
||||||
CopyGlobalJson(solutionRoot, destinationPath);
|
CopyGlobalJson(solutionRoot, destinationPath);
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[InitializeTestProject("AppWithP2PReference", "ClassLibrary")]
|
[InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")]
|
||||||
public async Task Publish_WithP2P_AndRazorCompileOnBuild_CopiesRazorAssembly()
|
public async Task Publish_WithP2P_AndRazorCompileOnBuild_CopiesRazorAssembly()
|
||||||
{
|
{
|
||||||
var result = await DotnetMSBuild("Publish");
|
var result = await DotnetMSBuild("Publish");
|
||||||
|
|
@ -276,7 +276,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[InitializeTestProject("AppWithP2PReference", "ClassLibrary")]
|
[InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")]
|
||||||
public async Task Publish_WithP2P_AndRazorCompileOnPublish_CopiesRazorAssembly()
|
public async Task Publish_WithP2P_AndRazorCompileOnPublish_CopiesRazorAssembly()
|
||||||
{
|
{
|
||||||
var result = await DotnetMSBuild("Publish");
|
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.dll");
|
||||||
Assert.FileExists(result, PublishOutputPath, "ClassLibrary.Views.pdb");
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[InitializeTestProject("SimpleMvc", "LinkedDir")]
|
[InitializeTestProject("SimpleMvc", additionalProjects: "LinkedDir")]
|
||||||
public async Task RazorGenerate_WorksWithLinkedFiles()
|
public async Task RazorGenerate_WorksWithLinkedFiles()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -300,7 +300,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[InitializeTestProject("SimpleMvc", "LinkedDir")]
|
[InitializeTestProject("SimpleMvc", additionalProjects: "LinkedDir")]
|
||||||
public async Task RazorGenerate_PrintsErrorsFromLinkedFiles()
|
public async Task RazorGenerate_PrintsErrorsFromLinkedFiles()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
namespace SimpleMvcFSharp
|
||||||
|
|
||||||
|
module Program =
|
||||||
|
let exitCode = 0
|
||||||
|
|
||||||
|
[<EntryPoint>]
|
||||||
|
let main args =
|
||||||
|
let t = typeof<Microsoft.AspNetCore.Mvc.IActionResult>
|
||||||
|
System.Console.WriteLine(t.FullName)
|
||||||
|
|
||||||
|
exitCode
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\</_RazorMSBuildRoot>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\build\netstandard2.0\Microsoft.AspNetCore.Razor.Design.props" />
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- Override for the MVC extension -->
|
||||||
|
<_MvcExtensionAssemblyPath>$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\bin\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll</_MvcExtensionAssemblyPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.props" />
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Models/ErrorViewModel.fs" />
|
||||||
|
<Compile Include="Program.fs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Test Placeholder -->
|
||||||
|
|
||||||
|
<Import Project="$(SolutionRoot)src\Microsoft.AspNetCore.Mvc.Razor.Extensions\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.targets" />
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "About";
|
||||||
|
}
|
||||||
|
<h2>@ViewData["Title"].</h2>
|
||||||
|
<h3>@ViewData["Message"]</h3>
|
||||||
|
|
||||||
|
<p>Use this area to provide additional information.</p>
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
@using SimpleMvcFSharp
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
Loading…
Reference in New Issue