From 2d5a1737a2aaebda1de080e001dd8382ff348046 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 20 Jun 2018 15:14:11 -0700 Subject: [PATCH] Update Razor SDK packing logic to not include Pack at properties layer. - Added test to verify that no-build scenarios work as expected. #2378 --- .../Sdk.Razor.CurrentVersion.props | 5 +-- .../Sdk.Razor.CurrentVersion.targets | 12 ++++++ .../IntegrationTests/PackIntegrationTest.cs | 40 +++++++++++++++++++ 3 files changed, 53 insertions(+), 4 deletions(-) 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 015a7953e8..2ac65f5424 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 @@ -67,10 +67,7 @@ Copyright (c) .NET Foundation. All rights reserved. - - $(IncludeRazorContentInPack) - - + diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 2e2dba43b1..d100b112cc 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -74,6 +74,11 @@ Copyright (c) .NET Foundation. All rights reserved. ResolveRazorGenerateInputs + + ResolveRazorGenerateInputs; + $(GenerateNuspecDependsOn) + + _RazorPrepareForRun; $(PrepareForRunDependsOn) @@ -326,6 +331,13 @@ Copyright (c) .NET Foundation. All rights reserved. + + + + + diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs index 317116111c..80bba18f13 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/PackIntegrationTest.cs @@ -15,6 +15,46 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { } + [Fact] + [InitializeTestProject("ClassLibrary")] + public async Task Pack__NoBuild_Works_IncludesRazorAssembly() + { + var result = await DotnetMSBuild("Build"); + Assert.BuildPassed(result); + + result = await DotnetMSBuild("Pack", "/p:NoBuild=true"); + Assert.BuildPassed(result); + + Assert.FileExists(result, OutputPath, "ClassLibrary.dll"); + Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll"); + + if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // Travis on OSX produces different full paths in C# and MSBuild + Assert.NuspecContains( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), + $""); + + Assert.NuspecDoesNotContain( + result, + Path.Combine("obj", Configuration, "ClassLibrary.1.0.0.nuspec"), + $""); + } + + 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", "netstandard2.0", "ClassLibrary.Views.dll")); + } + [Fact] [InitializeTestProject("ClassLibrary")] public async Task Pack_Works_IncludesRazorAssembly()