diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props
index 0d9f2603ab..00d411c6be 100644
--- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props
+++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props
@@ -18,6 +18,12 @@ Copyright (c) .NET Foundation. All rights reserved.
Default properties for common Razor SDK behavior.
-->
+
+ true
+
@@ -45,6 +51,13 @@ Copyright (c) .NET Foundation. All rights reserved.
-->
Implicit
+
+ false
+
@@ -52,7 +65,10 @@ Copyright (c) .NET Foundation. All rights reserved.
-
+
+ $(IncludeRazorContentInPack)
+
+
diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs
index 37427a1cc3..08cdb17f82 100644
--- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs
+++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/Assert.cs
@@ -233,6 +233,33 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
}
}
+ public static void NuspecDoesNotContain(MSBuildResult result, string nuspecPath, string expected)
+ {
+ if (result == null)
+ {
+ throw new ArgumentNullException(nameof(result));
+ }
+
+ if (nuspecPath == null)
+ {
+ throw new ArgumentNullException(nameof(nuspecPath));
+ }
+
+ if (expected == null)
+ {
+ throw new ArgumentNullException(nameof(expected));
+ }
+
+ nuspecPath = Path.Combine(result.Project.DirectoryPath, nuspecPath);
+ FileExists(result, nuspecPath);
+
+ var content = File.ReadAllText(nuspecPath);
+ if (content.Contains(expected))
+ {
+ throw new NuspecFoundException(result, nuspecPath, content, expected);
+ }
+ }
+
public static void NupkgContains(MSBuildResult result, string nupkgPath, string filePath)
{
if (result == null)
@@ -507,6 +534,34 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
}
}
+ private class NuspecFoundException : MSBuildXunitException
+ {
+ public NuspecFoundException(MSBuildResult result, string filePath, string content, string expected)
+ : base(result)
+ {
+ FilePath = filePath;
+ Content = content;
+ Expected = expected;
+ }
+
+ public string Content { get; }
+
+ public string Expected { get; }
+
+ public string FilePath { get; }
+
+ protected override string Heading
+ {
+ get
+ {
+ return
+ $"nuspec: '{FilePath}' should not contain the content {Expected}." +
+ Environment.NewLine +
+ $"actual content: {Content}";
+ }
+ }
+ }
+
private class NupkgFileMissingException : MSBuildXunitException
{
public NupkgFileMissingException(MSBuildResult result, string nupkgPath, string filePath)
diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs
index d060fc02b8..d95267414f 100644
--- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs
@@ -26,6 +26,39 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
$"");
+ Assert.NuspecDoesNotContain(
+ result,
+ Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"),
+ @"");
+
+ Assert.NupkgContains(
+ result,
+ Path.Combine("bin", Configuration, "ClassLibrary.1.0.0.nupkg"),
+ Path.Combine("lib", "netcoreapp2.0", "ClassLibrary.PrecompiledViews.dll"));
+ }
+
+ [Fact]
+ [InitializeTestProject("ClassLibrary")]
+ public async Task Pack_IncludesRazorFilesAsContent_WhenIncludeRazorContentInPack_IsSet()
+ {
+ var result = await DotnetMSBuild("Pack", "/p:RazorCompileOnBuild=true /p:IncludeRazorContentInPack=true");
+
+ Assert.BuildPassed(result);
+
+ Assert.FileExists(result, OutputPath, "ClassLibrary.dll");
+ Assert.FileExists(result, OutputPath, "ClassLibrary.PrecompiledViews.dll");
+
+ Assert.NuspecContains(
+ result,
+ Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"),
+ $"");
+
+ Assert.NuspecContains(
+ result,
+ Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"),
+ @"");
+
Assert.NupkgContains(
result,
Path.Combine("bin", Configuration, "ClassLibrary.1.0.0.nupkg"),
diff --git a/test/testapps/ClassLibrary/ClassLibrary.csproj b/test/testapps/ClassLibrary/ClassLibrary.csproj
index d3a47e0743..558cbea953 100644
--- a/test/testapps/ClassLibrary/ClassLibrary.csproj
+++ b/test/testapps/ClassLibrary/ClassLibrary.csproj
@@ -24,12 +24,6 @@
-
-
- false
-
-
-