Load the netcoreapp3.1 compiled task when running in Core MSBuild

Fixes https://github.com/aspnet/AspNetCore/issues/17308
\n\nCommit migrated from 51e2a0ee64
This commit is contained in:
Pranav K 2019-11-27 15:48:58 -08:00
parent 9328e4723e
commit 6ec0c445ce
4 changed files with 60 additions and 1 deletions

View File

@ -30,7 +30,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- Paths to tools, tasks, and extensions are calculated relative to the RazorSdkDirectoryRoot. This can be modified to test a local build. -->
<RazorSdkDirectoryRoot Condition="'$(RazorSdkDirectoryRoot)'==''">$(MSBuildThisFileDirectory)..\..\</RazorSdkDirectoryRoot>
<RazorSdkBuildTasksDirectoryRoot Condition="'$(RazorSdkBuildTasksDirectoryRoot)'==''">$(RazorSdkDirectoryRoot)tasks\</RazorSdkBuildTasksDirectoryRoot>
<_RazorSdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">$(DefaultNetCoreTargetFramework)</_RazorSdkTasksTFM>
<_RazorSdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">netcoreapp3.1</_RazorSdkTasksTFM>
<_RazorSdkTasksTFM Condition=" '$(_RazorSdkTasksTFM)' == ''">net46</_RazorSdkTasksTFM>
<RazorSdkBuildTasksAssembly>$(RazorSdkBuildTasksDirectoryRoot)$(_RazorSdkTasksTFM)\Microsoft.NET.Sdk.Razor.Tasks.dll</RazorSdkBuildTasksAssembly>
</PropertyGroup>

View File

@ -2,7 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Testing;
using Xunit;
namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
@ -221,5 +224,49 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.BuildOutputContainsLine(result, "Content: appsettings.json CopyToOutputDirectory= CopyToPublishDirectory=PreserveNewest ExcludeFromSingleFile=true");
Assert.BuildOutputContainsLine(result, "Content: appsettings.Development.json CopyToOutputDirectory= CopyToPublishDirectory=PreserveNewest ExcludeFromSingleFile=true");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task IntrospectRazorTasksDllPath()
{
// Regression test for https://github.com/aspnet/AspNetCore/issues/17308
var solutionRoot = GetType().Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
.First(a => a.Key == "Testing.RepoRoot")
.Value;
var tfm =
#if NETCOREAPP3_1
"netcoreapp3.1";
#else
#error Target framework needs to be updated.
#endif
var expected = Path.Combine(solutionRoot, "artifacts", "bin", "Microsoft.NET.Sdk.Razor", Configuration, "sdk-output", "tasks", tfm, "Microsoft.NET.Sdk.Razor.Tasks.dll");
// Verifies the fix for https://github.com/aspnet/AspNetCore/issues/17308
var result = await DotnetMSBuild("_IntrospectRazorTasks");
Assert.BuildPassed(result);
Assert.BuildOutputContainsLine(result, $"RazorTasksPath: {expected}");
}
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
[InitializeTestProject("SimpleMvc")]
public async Task IntrospectRazorTasksDllPath_DesktopMsBuild()
{
var solutionRoot = GetType().Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
.First(a => a.Key == "Testing.RepoRoot")
.Value;
var tfm = "net46";
var expected = Path.Combine(solutionRoot, "artifacts", "bin", "Microsoft.NET.Sdk.Razor", Configuration, "sdk-output", "tasks", tfm, "Microsoft.NET.Sdk.Razor.Tasks.dll");
// Verifies the fix for https://github.com/aspnet/AspNetCore/issues/17308
var result = await DotnetMSBuild("_IntrospectRazorTasks", msBuildProcessKind: MSBuildProcessKind.Desktop);
Assert.BuildPassed(result);
Assert.BuildOutputContainsLine(result, $"RazorTasksPath: {expected}");
}
}
}

View File

@ -53,6 +53,11 @@
<_Parameter2>$(ProcDumpPath)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>Testing.RepoRoot</_Parameter1>
<_Parameter2>$(RepoRoot)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
<!-- The test projects rely on these binaries being available -->

View File

@ -46,4 +46,11 @@
<Target Name="_IntrospectContentItems">
<Message Text="Content: %(Content.Identity) CopyToOutputDirectory=%(Content.CopyToOutputDirectory) CopyToPublishDirectory=%(Content.CopyToPublishDirectory) ExcludeFromSingleFile=%(Content.ExcludeFromSingleFile)" Importance="High" />
</Target>
<Target Name="_IntrospectRazorTasks">
<PropertyGroup>
<_SdkTaskPath>$([System.IO.Path]::GetFullPath('$(RazorSdkBuildTasksAssembly)'))</_SdkTaskPath>
</PropertyGroup>
<Message Text="RazorTasksPath: $(_SdkTaskPath)" Importance="High" />
</Target>
</Project>