diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets
index 84d7bb730c..e5e8d926a0 100644
--- a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets
+++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets
@@ -30,7 +30,7 @@ Copyright (c) .NET Foundation. All rights reserved.
$(MSBuildThisFileDirectory)..\..\
$(RazorSdkDirectoryRoot)tasks\
- <_RazorSdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">$(DefaultNetCoreTargetFramework)
+ <_RazorSdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">netcoreapp3.1
<_RazorSdkTasksTFM Condition=" '$(_RazorSdkTasksTFM)' == ''">net46
$(RazorSdkBuildTasksDirectoryRoot)$(_RazorSdkTasksTFM)\Microsoft.NET.Sdk.Razor.Tasks.dll
diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs
index fcb33acbf2..acff14237e 100644
--- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs
+++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs
@@ -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()
+ .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()
+ .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}");
+ }
}
}
diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/Microsoft.NET.Sdk.Razor.Test.csproj b/src/Razor/Microsoft.NET.Sdk.Razor/test/Microsoft.NET.Sdk.Razor.Test.csproj
index 0efaf7b8fd..e52fbfb440 100644
--- a/src/Razor/Microsoft.NET.Sdk.Razor/test/Microsoft.NET.Sdk.Razor.Test.csproj
+++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/Microsoft.NET.Sdk.Razor.Test.csproj
@@ -53,6 +53,11 @@
<_Parameter2>$(ProcDumpPath)
+
+ <_Parameter1>Testing.RepoRoot
+ <_Parameter2>$(RepoRoot)
+
+
diff --git a/src/Razor/test/testassets/RazorTest.Introspection.targets b/src/Razor/test/testassets/RazorTest.Introspection.targets
index c3fca78317..de0fc9ee3e 100644
--- a/src/Razor/test/testassets/RazorTest.Introspection.targets
+++ b/src/Razor/test/testassets/RazorTest.Introspection.targets
@@ -46,4 +46,11 @@
+
+
+
+ <_SdkTaskPath>$([System.IO.Path]::GetFullPath('$(RazorSdkBuildTasksAssembly)'))
+
+
+