From bf52e0dbf0c2467b2beb76b673be558073476a98 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 4 Jan 2018 11:55:15 -0800 Subject: [PATCH] Add support for CopyBuildOutputToOutputDirectory and CopyOutputSymbolsToOutputDirectory Fixes #1896 --- ...spNetCore.Razor.Design.Compilation.targets | 167 ++++++++++++++++++ .../Microsoft.AspNetCore.Razor.Design.targets | 125 +------------ .../IntegrationTests/BuildIntegrationTest.cs | 45 +++++ 3 files changed, 215 insertions(+), 122 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets diff --git a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets new file mode 100644 index 0000000000..07b2207f92 --- /dev/null +++ b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.Compilation.targets @@ -0,0 +1,167 @@ + + + + + + + <_RazorIntermediateAssembly Include="$(IntermediateOutputPath)$(RazorTargetName).dll" /> + + + <_RazorIntermediatePdb + Condition="'$(DebugSymbols)'=='true' and '$(DebugType)'!='' and '$(DebugType)'!='none' and '$(DebugType)'!='embedded'" + Include="$(IntermediateOutputPath)$(RazorTargetName).pdb" /> + + + + + + + $(NoWarn);1701;1702 + + + + + $(NoWarn);2008 + + + + + + + + + + + $(AppConfig) + + + + + false + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.targets b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.targets index 0914cdc451..6f04f0fcaf 100644 --- a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.targets +++ b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.targets @@ -2,6 +2,8 @@ + + @@ -9,7 +11,7 @@ - $(BuildDependsOn);RazorCompile + RazorCompile;$(PrepareForRunDependsOn) - <_RazorIntermediateAssembly>$(IntermediateOutputPath)$(RazorTargetName).dll - <_RazorIntermediatePdb>$(IntermediateOutputPath)$(RazorTargetName).pdb - <_RazorGenerateToolAssembly>$(_RazorMSBuildRoot)tools\Microsoft.AspNetCore.Razor.GenerateTool.dll <_RazorTagHelperToolAssembly>$(_RazorMSBuildRoot)tools\Microsoft.AspNetCore.Razor.TagHelperTool.dll @@ -142,121 +140,4 @@ - - - - - - - $(NoWarn);1701;1702 - - - - - $(NoWarn);2008 - - - - - - - - - - - $(AppConfig) - - - - - false - - - - true - - - - - - - - - - diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs index 7b82f60110..92f9691a02 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs @@ -69,5 +69,50 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileExists(result, IntermediateOutputPath, "SimplePages.dll"); Assert.FileExists(result, IntermediateOutputPath, "SimplePages.PrecompiledViews.dll"); } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_SkipsCopyingBinariesToOutputDirectory_IfCopyBuildOutputToOutputDirectory_IsUnset() + { + var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true /p:CopyBuildOutputToOutputDirectory=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.PrecompiledViews.dll"); + + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.PrecompiledViews.dll"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_SkipsCopyingBinariesToOutputDirectory_IfCopyOutputSymbolsToOutputDirectory_IsUnset() + { + var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true /p:CopyOutputSymbolsToOutputDirectory=false"); + + Assert.BuildPassed(result); + + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.PrecompiledViews.pdb"); + + Assert.FileExists(result, OutputPath, "SimpleMvc.PrecompiledViews.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.PrecompiledViews.pdb"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task Build_Works_WhenSymbolsAreNotGenerated() + { + var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=true /p:DebugType=none"); + + Assert.BuildPassed(result); + + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.pdb"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.PrecompiledViews.pdb"); + + Assert.FileExists(result, OutputPath, "SimpleMvc.PrecompiledViews.dll"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.pdb"); + Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.PrecompiledViews.pdb"); + } } }