parent
4c8c86b629
commit
8d99ba53ce
|
|
@ -74,6 +74,11 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
$(PrepareForRunDependsOn)
|
$(PrepareForRunDependsOn)
|
||||||
</PrepareForRunDependsOn>
|
</PrepareForRunDependsOn>
|
||||||
|
|
||||||
|
<GetCopyToOutputDirectoryItemsDependsOn>
|
||||||
|
_RazorGetCopyToOutputDirectoryItems;
|
||||||
|
$(GetCopyToOutputDirectoryItems)
|
||||||
|
</GetCopyToOutputDirectoryItemsDependsOn>
|
||||||
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
@ -266,6 +271,9 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<!--
|
<!--
|
||||||
Gathers input source files for code generation. This is a separate target so that we can avoid
|
Gathers input source files for code generation. This is a separate target so that we can avoid
|
||||||
lots of work when there are no inputs for code generation.
|
lots of work when there are no inputs for code generation.
|
||||||
|
|
||||||
|
NOTE: This target is called as part of an incremental build scenario in VS. Do not perform any work
|
||||||
|
outside of calculating RazorGenerate items in this target.
|
||||||
-->
|
-->
|
||||||
<Target Name="ResolveRazorGenerateInputs">
|
<Target Name="ResolveRazorGenerateInputs">
|
||||||
<!--
|
<!--
|
||||||
|
|
@ -384,7 +392,7 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
-->
|
-->
|
||||||
<Target
|
<Target
|
||||||
Name="_RazorGetCopyToOutputDirectoryItems"
|
Name="_RazorGetCopyToOutputDirectoryItems"
|
||||||
BeforeTargets="GetCopyToOutputDirectoryItems"
|
DependsOnTargets="ResolveRazorGenerateInputs"
|
||||||
Condition="'$(ResolvedRazorCompileToolset)'=='RazorSdk' and '$(RazorCompileOnBuild)'=='true'">
|
Condition="'$(ResolvedRazorCompileToolset)'=='RazorSdk' and '$(RazorCompileOnBuild)'=='true'">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,30 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
throw new BuildOutputMissingException(result, match);
|
throw new BuildOutputMissingException(result, match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void BuildOutputDoesNotContainLine(MSBuildResult result, string match)
|
||||||
|
{
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(match));
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't really need to search line by line, I'm doing this so that it's possible/easy to debug.
|
||||||
|
var lines = result.Output.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
for (var i = 0; i < lines.Length; i++)
|
||||||
|
{
|
||||||
|
var line = lines[i].Trim();
|
||||||
|
if (line == match)
|
||||||
|
{
|
||||||
|
throw new BuildOutputContainsLineException(result, match);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void FileContains(MSBuildResult result, string filePath, string match)
|
public static void FileContains(MSBuildResult result, string filePath, string match)
|
||||||
{
|
{
|
||||||
if (result == null)
|
if (result == null)
|
||||||
|
|
@ -432,6 +456,19 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
protected override string Heading => $"Build did not contain the line: '{Match}'.";
|
protected override string Heading => $"Build did not contain the line: '{Match}'.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class BuildOutputContainsLineException : MSBuildXunitException
|
||||||
|
{
|
||||||
|
public BuildOutputContainsLineException(MSBuildResult result, string match)
|
||||||
|
: base(result)
|
||||||
|
{
|
||||||
|
Match = match;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Match { get; }
|
||||||
|
|
||||||
|
protected override string Heading => $"Build output contains the line: '{Match}'.";
|
||||||
|
}
|
||||||
|
|
||||||
private class FileContentFoundException : MSBuildXunitException
|
private class FileContentFoundException : MSBuildXunitException
|
||||||
{
|
{
|
||||||
public FileContentFoundException(MSBuildResult result, string filePath, string content, string match)
|
public FileContentFoundException(MSBuildResult result, string filePath, string content, string match)
|
||||||
|
|
|
||||||
|
|
@ -136,5 +136,42 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
Assert.FileDoesNotExist(result, IntermediateOutputPath, "Razor", "Views", "Home", "Index.cshtml.g.cs");
|
Assert.FileDoesNotExist(result, IntermediateOutputPath, "Razor", "Views", "Home", "Index.cshtml.g.cs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[InitializeTestProject("AppWithP2PReference", additionalProjects: "ClassLibrary")]
|
||||||
|
public async Task IncrementalBuild_WithP2P_WorksWhenBuildProjectReferencesIsDisabled()
|
||||||
|
{
|
||||||
|
// Simulates building the same way VS does by setting BuildProjectReferences=false.
|
||||||
|
// With this flag, the only target called is GetCopyToOutputDirectoryItems on the referenced project.
|
||||||
|
// We need to ensure that we continue providing Razor binaries and symbols as files to be copied over.
|
||||||
|
var result = await DotnetMSBuild(target: default);
|
||||||
|
|
||||||
|
Assert.BuildPassed(result);
|
||||||
|
|
||||||
|
Assert.FileExists(result, OutputPath, "AppWithP2PReference.dll");
|
||||||
|
Assert.FileExists(result, OutputPath, "AppWithP2PReference.Views.dll");
|
||||||
|
Assert.FileExists(result, OutputPath, "ClassLibrary.dll");
|
||||||
|
Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll");
|
||||||
|
Assert.FileExists(result, OutputPath, "ClassLibrary.Views.pdb");
|
||||||
|
|
||||||
|
result = await DotnetMSBuild(target: "Clean", "/p:BuildProjectReferences=false", suppressRestore: true);
|
||||||
|
Assert.BuildPassed(result);
|
||||||
|
|
||||||
|
Assert.FileDoesNotExist(result, OutputPath, "AppWithP2PReference.dll");
|
||||||
|
Assert.FileDoesNotExist(result, OutputPath, "AppWithP2PReference.Views.dll");
|
||||||
|
Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.dll");
|
||||||
|
Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.Views.dll");
|
||||||
|
Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.Views.pdb");
|
||||||
|
|
||||||
|
// dotnet msbuild /p:BuildProjectReferences=false
|
||||||
|
result = await DotnetMSBuild(target: default, "/p:BuildProjectReferences=false", suppressRestore: true);
|
||||||
|
|
||||||
|
Assert.BuildPassed(result);
|
||||||
|
Assert.FileExists(result, OutputPath, "AppWithP2PReference.dll");
|
||||||
|
Assert.FileExists(result, OutputPath, "AppWithP2PReference.Views.dll");
|
||||||
|
Assert.FileExists(result, OutputPath, "ClassLibrary.dll");
|
||||||
|
Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll");
|
||||||
|
Assert.FileExists(result, OutputPath, "ClassLibrary.Views.pdb");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,5 +45,31 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
Assert.BuildPassed(result);
|
Assert.BuildPassed(result);
|
||||||
Assert.BuildOutputContainsLine(result, "UseRazorBuildServer: false");
|
Assert.BuildOutputContainsLine(result, "UseRazorBuildServer: false");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[InitializeTestProject("ClassLibrary")]
|
||||||
|
public async Task GetCopyToOutputDirectoryItems_WhenNoFileIsPresent_ReturnsEmptySequence()
|
||||||
|
{
|
||||||
|
var result = await DotnetMSBuild(target: default);
|
||||||
|
|
||||||
|
Assert.BuildPassed(result);
|
||||||
|
|
||||||
|
Assert.FileExists(result, OutputPath, "ClassLibrary.dll");
|
||||||
|
Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll");
|
||||||
|
|
||||||
|
result = await DotnetMSBuild(target: "GetCopyToOutputDirectoryItems", "/t:_IntrospectGetCopyToOutputDirectoryItems /p:BuildProjectReferences=false", suppressRestore: true);
|
||||||
|
Assert.BuildPassed(result);
|
||||||
|
Assert.BuildOutputContainsLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.dll");
|
||||||
|
Assert.BuildOutputContainsLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.pdb");
|
||||||
|
|
||||||
|
// Remove all views from the class library
|
||||||
|
Directory.Delete(Path.Combine(Project.DirectoryPath, "Views"), recursive: true);
|
||||||
|
|
||||||
|
// dotnet msbuild /p:BuildProjectReferences=false
|
||||||
|
result = await DotnetMSBuild(target: "GetCopyToOutputDirectoryItems", "/t:_IntrospectGetCopyToOutputDirectoryItems /p:BuildProjectReferences=false", suppressRestore: true);
|
||||||
|
|
||||||
|
Assert.BuildOutputDoesNotContainLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.dll");
|
||||||
|
Assert.BuildOutputDoesNotContainLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.pdb");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,8 @@
|
||||||
<Target Name="_IntrospectUseRazorBuildServer">
|
<Target Name="_IntrospectUseRazorBuildServer">
|
||||||
<Message Text="UseRazorBuildServer: $(UseRazorBuildServer)" Importance="High" />
|
<Message Text="UseRazorBuildServer: $(UseRazorBuildServer)" Importance="High" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="_IntrospectGetCopyToOutputDirectoryItems">
|
||||||
|
<Message Text="AllItemsFullPathWithTargetPath: %(AllItemsFullPathWithTargetPath.TargetPath)" Importance="High" />
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue