Merge remote-tracking branch 'origin/release/2.1' into dev

This commit is contained in:
Ryan Nowak 2018-02-01 13:36:07 -08:00
commit e3932aa1ec
7 changed files with 62 additions and 2 deletions

View File

@ -61,6 +61,18 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
msBuildProcessKind);
}
internal void AddProjectFileContent(string content)
{
if (content == null)
{
throw new ArgumentNullException(nameof(content));
}
var existing = File.ReadAllText(Project.ProjectFilePath);
var updated = existing.Replace("<!-- Test Placeholder -->", content);
File.WriteAllText(Project.ProjectFilePath, updated);
}
internal void ReplaceContent(string content, params string[] paths)
{
if (content == null)

View File

@ -57,7 +57,10 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
CopyGlobalJson(solutionRoot, destinationPath);
return new ProjectDirectory(destinationPath, Path.Combine(destinationPath, projectName));
return new ProjectDirectory(
destinationPath,
Path.Combine(destinationPath, projectName),
Path.Combine(destinationPath, projectName, projectName + ".csproj"));
}
catch
{
@ -119,14 +122,17 @@ $@"<Project>
}
}
private ProjectDirectory(string solutionPath, string directoryPath)
private ProjectDirectory(string solutionPath, string directoryPath, string projectFilePath)
{
SolutionPath = solutionPath;
DirectoryPath = directoryPath;
ProjectFilePath = projectFilePath;
}
public string DirectoryPath { get; }
public string ProjectFilePath { get;}
public string SolutionPath { get; }
public void Dispose()

View File

@ -244,5 +244,37 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "Home", "About.cs");
Assert.FileCountEquals(result, 1, RazorIntermediateOutputPath, "*.cs");
}
[Fact(Skip = "Fails due to #1999")]
[InitializeTestProject("SimpleMvc")]
public async Task RazorGenerate_FileWithAbsolutePath_IgnoresFile()
{
// In preview1 we totally ignore files that are specified with an absolute path
var filePath = Path.Combine(Project.SolutionPath, "temp.cshtml");
File.WriteAllText(filePath, string.Empty);
AddProjectFileContent($@"
<ItemGroup>
<Content Include=""{filePath}""/>
</ItemGroup>");
var result = await DotnetMSBuild(RazorGenerateTarget);
Assert.BuildPassed(result);
// RazorGenerate should compile the assembly, but not the views.
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.PrecompiledViews.dll");
Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "_ViewImports.cs");
Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "_ViewStart.cs");
Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "Home", "About.cs");
Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "Home", "Contact.cs");
Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "Home", "Index.cs");
Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "Shared", "_Layout.cs");
Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "Shared", "_ValidationScriptsPartial.cs");
Assert.FileExists(result, RazorIntermediateOutputPath, "Views", "Shared", "Error.cs");
Assert.FileCountEquals(result, 8, RazorIntermediateOutputPath, "*.cs");
}
}
}

View File

@ -13,6 +13,8 @@
<ResolvedRazorCompileToolset Condition="'$(RazorCompileToolset)'==''">RazorSDK</ResolvedRazorCompileToolset>
</PropertyGroup>
<!-- Test Placeholder -->
<ItemGroup>
<ProjectReference Include="..\ClassLibrary\ClassLibrary.csproj"/>
</ItemGroup>

View File

@ -13,6 +13,8 @@
<ResolvedRazorCompileToolset Condition="'$(RazorCompileToolset)'==''">RazorSDK</ResolvedRazorCompileToolset>
</PropertyGroup>
<!-- Test Placeholder -->
<ItemGroup>
<Content Include="**\*.cshtml">
<Pack>false</Pack>

View File

@ -12,4 +12,7 @@
<!-- Workaround until we get a new SDK build -->
<ResolvedRazorCompileToolset Condition="'$(RazorCompileToolset)'==''">RazorSDK</ResolvedRazorCompileToolset>
</PropertyGroup>
<!-- Test Placeholder -->
</Project>

View File

@ -12,4 +12,7 @@
<!-- Workaround until we get a new SDK build -->
<ResolvedRazorCompileToolset Condition="'$(RazorCompileToolset)'==''">RazorSDK</ResolvedRazorCompileToolset>
</PropertyGroup>
<!-- Test Placeholder -->
</Project>