Don't publish the refs directory when the app does not have any Razor files

Fixes https://github.com/aspnet/Razor/issues/2246
This commit is contained in:
Pranav K 2018-04-11 14:45:44 -07:00
parent 6d9df1ef33
commit 9365fcd053
2 changed files with 9 additions and 2 deletions

View File

@ -492,17 +492,21 @@ Copyright (c) .NET Foundation. All rights reserved.
<ItemGroup Condition="'$(CopyRazorGenerateFilesToPublishDirectory)'=='false'">
<ResolvedFileToPublish Remove="%(RazorGenerate.FullPath)"/>
</ItemGroup>
</Target>
<Target
Name="_RazorRemoveRefAssembliesFromPublish"
AfterTargets="ComputeRefAssembliesToPublish"
Condition="'$(ResolvedRazorCompileToolset)'=='RazorSdk' and '$(RazorCompileOnPublish)'=='true' and '$(CopyRefAssembliesToPublishDirectory)'=='false'">
<!--
The ref assemblies are published whenever PreserveCompilationContext is true, which we expect to be true for
most usages of Razor. There's no setting that excludes just the ref assemblies, so we do it ourselves.
-->
<ItemGroup Condition="'$(CopyRefAssembliesToPublishDirectory)'=='false'">
<ItemGroup>
<ResolvedFileToPublish
Remove="%(ResolvedFileToPublish.Identity)"
Condition="'%(ResolvedFileToPublish.RelativePath)'=='$(RefAssembliesFolderName)\%(Filename)%(Extension)'"/>
</ItemGroup>
</Target>
<Target Name="_CheckForMissingRazorCompiler" Condition="'$(IsRazorCompilerReferenced)' != 'true'">

View File

@ -142,6 +142,9 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileExists(result, PublishOutputPath, "SimpleMvc.pdb");
Assert.FileDoesNotExist(result, PublishOutputPath, "SimpleMvc.Views.dll");
Assert.FileDoesNotExist(result, PublishOutputPath, "SimpleMvc.Views.pdb");
// By default refs will not be copied on publish
Assert.FileCountEquals(result, 0, Path.Combine(PublishOutputPath, "refs"), "*.dll");
}
[Fact]